代码之家  ›  专栏  ›  技术社区  ›  andrea

水平对齐列表ViewItem

  •  0
  • andrea  · 技术社区  · 13 年前

    我需要将我的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>
    

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

    非常感谢。

    1 回复  |  直到 13 年前
        1
  •  3
  •   Bas Peeters rshivamca    11 年前

    您可以为您的 列表视图 :

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