Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF ListView VerticalScrollBar is not shown

I'm displaying a collection of items on a ListView. The collection is long enough to show the VerticalScrollBar of the ListView but it doesn't work.

My XAML:

<UserControl>
    <Grid>
        <ListView ItemsSource="{Binding MyCollection}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn DisplayMemberBinding="{Binding MyProperty}" Header="MyProperty" />
                        ...
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>

My UserControl is used like this:

<Window>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0" IsMainMenu="True">
            <MenuItem Header="_File" />
            ...
        </Menu>
        <TabControl Grid.Row="1" >
            <TabItem Header="myUserControl">
                <views:MyUserControl />
            </TabItem>
            ...
        </TabControl>
        ...
    </Grid>
</Window>
like image 571
Stacked Avatar asked Jan 14 '23 05:01

Stacked


1 Answers

Found it. The height of the Grid Row modified from "Auto" to "*".

<!-- Row where the ListView is shown -->
<RowDefinition Height="*" />
like image 173
Stacked Avatar answered Jan 22 '23 05:01

Stacked