-3

I have a horizontal stackpanel that includes many vertical stackpanels.

this image

The above image shows the stackpanel have 20 items but shows only 12 items to us. The problem is how can we scroll it in horizontal dimension to show all elements?

Vikrant
  • 4,920
  • 17
  • 48
  • 72
  • You might be looking for a `ScrollViewer`: http://www.blackwasp.co.uk/WPFScrollViewer.aspx – Markus Deibel Aug 27 '19 at 04:22
  • The usual way to produce something like that is to use a listbox or listview. Change the itemspresenter to an orientation horizontal stackpanel. Bind an obseervablecollection of viewmodels to the itemssource. Template out each viewmodel into each item – Andy Aug 27 '19 at 07:54

1 Answers1

1

You can put your StackPanel inside a ScrollViewer like this:

<ScrollViewer 
    HorizontalScrollBarVisibility="Auto"
    VerticalScrollBarVisibility="Disabled">
    <StackPanel Orientation="Horizontal">
        <Label>Item 1</Label>
        <Label>Item 2</Label>
        <Label>Item 3</Label>
        <Label>Item 4</Label>
        <Label>Item 5</Label>
        <Label>Item 6</Label>
        <Label>Item 7</Label>
        <Label>Item 8</Label>
        <Label>Item 9</Label>
        <Label>Item 10</Label>
    </StackPanel>
</ScrollViewer>

Output:

enter image description here

AmRo
  • 833
  • 1
  • 8
  • 19
  • i did it but didnt work. my stackpanel have many smaller stackpanels in it. actually it is a stackpanel of many stackpanels. in this condition scrolbar doesnt work – siamak work Aug 27 '19 at 07:27
  • Which is not particularly obvious from your post and why you should have provided a minimal reproducible example https://stackoverflow.com/help/minimal-reproducible-example. – Andy Aug 27 '19 at 07:57
  • @Andy please read question title on top of page. btw, i didnt find any useful answer for my problem yet – siamak work Aug 27 '19 at 09:19
  • You still haven't provided a minimal reproducible example. No markup. No code. – Andy Aug 27 '19 at 11:30