【问题标题】:Horizontal Alignment ListViewItem水平对齐 ListViewItem
【发布时间】:2013-02-02 20:10:40
【问题描述】:

我需要将我的 listviewitems 水平放置,但我找不到方法,到目前为止我试过这个:

 <ListView Grid.Row="0" ItemsSource="{Binding Path=Cells, UpdateSourceTrigger=PropertyChanged}" 
                        ItemTemplate="{StaticResource CellGroupTemplate}"
                        Background="{StaticResource EnvLayout}"
                        HorizontalContentAlignment="Stretch">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Style.Resources>
                                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                            </Style.Resources>
                        </Style>
                    </ListView.ItemContainerStyle>
                </ListView>

我的项目是其他 UI 控件,附加了它们的视图模型

 <DataTemplate DataType="{x:Type vm:CellItemViewModel}" x:Key="CellGroupTemplate">
        <vw:CellItemView/>
    </DataTemplate>

谁能告诉我如何将每个元素(数据模板)放在另一个旁边

谢谢

【问题讨论】:

    标签: wpf alignment listviewitem


    【解决方案1】:

    您可以为您的 ListView 设置自定义项目面板:

     <ListView>
         <ListView.ItemsPanel>
             <ItemsPanelTemplate>
                 <StackPanel Orientation="Horizontal" />
             </ItemsPanelTemplate>
         </ListView.ItemsPanel>
     </ListView>
    

    【讨论】:

      猜你喜欢
      • 2013-04-16
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-15
      • 2016-10-27
      • 2020-01-08
      相关资源
      最近更新 更多