WPF ListView VerticalScrollBar 未显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16963535/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:56:48  来源:igfitidea点击:

WPF ListView VerticalScrollBar is not shown

wpfxamlscrollbar

提问by Stacked

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.

我在 ListView 上显示一组项目。该集合足够长以显示 ListView 的 VerticalScrollBar 但它不起作用。

My XAML:

我的 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:

我的 UserControl 是这样使用的:

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

回答by Stacked

Found it. The height of the GridRowmodified from "Auto"to "*".

找到了。的高度GridRow从改性"Auto""*"

<!-- Row where the ListView is shown -->
<RowDefinition Height="*" />