0
请帮助我解决WPF listview中滚动条可见性问题。 我有一个内容控件内的列表视图。 此内容控件位于用户控件中。 此用户控件位于TabItem中。ScrollBar没有显示在嵌套用户和内容控件中的WPF ListView中
listview有大约12列显示,超过了窗口宽度。 我尝试了很多方式来显示列表视图中的水平滚动条。
下面示出的是外用户控件的XAML [宽度不设置此外usrCrtl]
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> // Here I have a custom content control
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<MyCustomContentControl Grid.Row=1 VerticalAlignment="Stretch"......>
<TabControl>
<TabItem Header="One" Name="Tab1">
<my:usrAControl /> // I have listview inside this userctrl
</TabItem>
</TabControl>
<TabControl Header="Two" Name="Tab2" />
</MyCustomContentControl>
</Grid>
现在下面是usrAControl XAML详细
<UserControl x:Class="MyProject.MyModule.usrAControl"
MinWidth="640">
// Again inside another custom user control as its child.
<usrBControl>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" /> // here another headers
<RowDefinition Height="*" /> // here my listview placed
</Grid.RowDefinitions>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Auto" Grid.Row="1"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Width}">
// Around 12 columns which exceeds window width
</ListView>
</Grid>
</usrBControl>
</usrAControl>
我试图与很多组合的。 我最初把一个scrollviewer控件放在tabitem里面,并把usrAControl放在里面。 但它没有奏效。
但我想列表视图应该显示它的两个滚动条。有没有办法做到这一点。?
嗨Eli Arbel,我通过删除MinWidth和ListView宽度绑定再次尝试,仍然没有用。任何其他方式? – user2846545
然后你必须添加更多的代码。 'usrBControl'和'MyCustomContentControl'中有什么?代码是可行的。 –
嗨Eli,我通过将scrollviewer作为父列表视图来修复它。所以现在这两个滚动条都可见。感谢您的时间,建议和帮助 – user2846545