SelectionMode
Single Mulle Extended
<ListBox Name="lsTest">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem>Item1</ListBoxItem>
<ListBoxItem>Item2</ListBoxItem>
<ListBoxItem>Item3</ListBoxItem>
</ListBox>
与以下代码效果相同:
FrameworkElementFactory panelFactory = new FrameworkElementFactory
(typeof(VirtualizingStackPanel));
panelFactory.SetValue(VirtualizingStackPanel.OrientationProperty, Orientation.Horizontal);
this.lsTest.ItemsPanel = new ItemsPanelTemplate(panelFactory);