Ayman Salah
Ayman Salah

Reputation: 1089

WPF stackpanel scrolling issues

i have this in my window and i'll be adding items programmatically to these stacks. problem is i can't scroll through my stuff. i have tried everything that i can find online but i couldn't.

<Border x:Name="Border_Output" Width="463" Height="463" CornerRadius="30" 
                                    BorderThickness="0" Background="White">
    <Grid>
        <StackPanel x:Name="Restaurant_SearchOutputStack"/>
        <StackPanel x:Name="Item_SearchOutputStack"/>
        <StackPanel x:Name="Order_OutputStack"/>
        <StackPanel x:Name="Menu_OutputStack"/>
    </Grid>
</Border>

Upvotes: 0

Views: 773

Answers (2)

Noctis
Noctis

Reputation: 11783

If you have a stackpanel, it is assigned the size of it's items, so the scrollerbar won't appear.

From this article:

As you can see, having a ListBox in a StackPanel causes the ScrollViewer to disappear, since the StackPanel gives its children the entire size they need, rendering the collection without the ScrollViewer.

Upvotes: 3

Ayman Salah
Ayman Salah

Reputation: 1089

i found the answer.. it was to have it this way instead.

<ScrollViewer VerticalScrollBarVisibility="Auto">
                        <Grid>
                            <StackPanel x:Name="Restaurant_SearchOutputStack"/>
                            <StackPanel x:Name="Item_SearchOutputStack"/>
                            <StackPanel x:Name="Order_OutputStack"/>
                            <StackPanel x:Name="Menu_OutputStack"/>
                        </Grid>
                    </ScrollViewer>

and because when i use one stack i collapse the others what i want happens correctly. thanks anyways guys.

Upvotes: 0

Related Questions