私は WPF を使い始めたばかりで、スクロール可能なリストを作成する方法がわかりません。カスタムオブジェクトをその中に入れて、横にスクロールできるようにしたいです。
どこから始めればよいか考えている人はいますか?
スクロールを水平方向に作成するの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
ようなコントロールを操作するいくつかの基本的な例を試してみてください。
その後、ほとんどの場合、カスタム オブジェクトのコレクションをそれListBox
を介してバインドし、カスタム オブジェクトを視覚化するのに役立つ を xaml で定義します。ItemSource
DataTemplate
その ^^ ステートメント ( Binding
、ItemSource
、DataTemplate
) のほとんどすべての技術的な単語は、最初に理解したいと思います。新しいものではなく、検索するだけでそれぞれの広範なヘルプを見つけることができます。