0

请帮助我解决 WPF listview 中滚动条可见性的问题。我在内容控件中有一个列表视图。此内容控件位于用户控件内。此用户控件位于 TabItem 内。

列表视图有大约 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>

我尝试了很多组合。我最初在 tabitem 中放置了一个滚动查看器控件,并将 usrAControl 放置在其中。但它没有用。

但我希望列表视图应该显示它的两个滚动条。有什么办法吗。?

4

1 回答 1

0

Without seeing more code, my guess would be that the MinSize="640" is your problem: the ListView gets enough space from its container so it doesn't show the scroll, but the container gets clipped.

And you should get rid of the ListView Width binding, it's completely redundant.

于 2013-10-06T05:10:34.977 回答