2013-07-06 42 views

回答

1

制作ListBox水平滚动很简单:

<ListBox Margin="20"> 
    <ListBox.ItemsPanel> 
    <ItemsPanelTemplate> 
     <!-- If you need Virtualization then check up on that topic accordingly and you'd need to switch the following StackPanel to a VirtualizingStackPanel --> 
     <StackPanel Orientation="Horizontal" /> 
    </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
    <ListBoxItem Content="Something A" /> 
    <ListBoxItem Content="Something B" /> 
    <ListBoxItem Content="Something C" /> 
    <ListBoxItem Content="Something D" /> 
    <ListBoxItem Content="Something E" /> 
    <ListBoxItem Content="Something F" /> 
</ListBox> 

对于自定义对象的一部分,试着去先通过与ListBox控制工作的一些基本的例子说喜欢These

你会则非常简单,只是有你绑定到ListBox自定义对象的集合通过它的ItemSource,然后在XAML定义DataTemplate的,这将有助于可视化的自定义对象。

差不多在^^声明(BindingItemSourceDataTemplate)你想了解第一,你可以只是在寻找,AINT新的东西找到大量的帮助,每个每易怒字。

+0

在大多数情况下,您应该使用'VirtualizingStackPanel'而不是'StackPanel'作为'ItemPanelTemplate'的方向。 –

+0

@SimonBelanger这就是UI中的要求。通过'ItemsPanelTemplate'实现'Orientation'的概念就是我想传达的内容,而不是实际的控制。我会将它添加为xaml中的注释,尽管如此 – Viv

+0

我同意。我意识到它可能听起来像是这样,但我并不反对你,只是增加了你的答案。 ;) –