1

我正在尝试在列表框/包装面板上获得另一种行颜色效果。但是,由于方向是水平的,因此备用列正在获取备用颜色。我希望元素以侧面方式列出然后包装。如何基于此在行上设置备用颜色。

<ListBox ItemsSource="{Binding MySource}"  ItemContainerStyle="{StaticResource alternatingListItemStyle}" AlternationCount="2">
 <ListBox.ItemsPanel>
     <ItemsPanelTemplate>
         <WrapPanel Orientation="Horizontal" MaxWidth="300"/>
     </ItemsPanelTemplate>
 </ListBox.ItemsPanel>
 <ListBox.ItemTemplate>
     <DataTemplate>
         <CheckBox Content="{Binding MyCaption}"/>
     </DataTemplate>
 </ListBox.ItemTemplate>

4

1 回答 1

0

The possible reason for alternating color for columns is the 'MaxWidth'. As the MaxWidth for WrapPanel is 300, it's possible to hold more than one item. If you reduce the maxwidth, it may hold a single item. Hope this helps.

(Can you explain why you are using a wrap panel in ItemsPanelTemplate? I am not sure how you want the output to look like.)

于 2012-08-12T02:39:42.943 回答