Anthony
Anthony

Reputation: 81

making a custom list that scrolls horizontally

I just started with WPF and I have no idea how I would go about making a scrollable list. I want to be able to put a custom object inside of it and then scroll sideways.

Is there anyone that may have any idea where to start?

Upvotes: 1

Views: 107

Answers (1)

Viv
Viv

Reputation: 17380

making a ListBox scroll Horizontally is pretty simple:

<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>

As for the custom object part, Try to firstly go through some basic examples of working with a ListBox control say like These.

You'd then pretty much just have your collection of custom objects Bound to the ListBox via it's ItemSource and then have DataTemplate's defined in xaml that would help visualise your custom objects.

Pretty much every techy word in that^^ statement(Binding, ItemSource, DataTemplate) you'd want to understand first and you can find extensive help with each by just searching, aint something new.

Upvotes: 1

Related Questions