2013-02-18 113 views
0

我需要把我的listviewitems橫向上,但我不能找到辦法,到目前爲止,我嘗試這樣做:水平對齊的ListViewItem

<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> 

誰能告訴我怎麼把每個元素(DataTemplate中)旁邊的其他

謝謝

回答

2

您可以設置自定義項目小組爲您的ListView

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