Cod Fish
Cod Fish

Reputation: 947

VerticalScrollBar for a listbox inside an Expander - WPF

I'm working on a WPF application. I have a listbox inside an Expander, and what I want to do is for the list box to have a vertical scroll bar. Here is my code:

<Expander Grid.Row="1" Header="More Details" >
    <ListBox ScrollViewer.VerticalScrollBarVisibility="Visible" 
             Height="20"
             ItemsSource="{Binding Path=DetailsItemsSource, Mode=TwoWay}" 
             ItemTemplate="{Binding Path=DetailsTemplate, Mode=TwoWay}">
    </ListBox>
</Expander>

I can see a scrollbar area in the listbox , but no scrollbar itself (even when there are unseen items). Thanks!

Upvotes: 1

Views: 1188

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Change the layout to remove the Expander and use Grid and see if that helps.Another solution will be you need to set the Height property of ScrollViewer.Something like this,

<Expander Header="expander1" Width="150" HorizontalAlignment="Left">
                <ScrollViewer Height="75">
                    <ListBox>

                    </ListBox>
                </ScrollViewer>
</Expander>

Upvotes: 2

Related Questions