2013-07-06 40 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

我同意。我意識到它可能聽起來像是這樣,但我並不反對你,只是增加了你的答案。 ;) –