列表视图上没有滚动条 [英] No scrollbar on listview
本文介绍了列表视图上没有滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个窗口
< Window x:Class =AnalyzeSMlogs.ListViewTest
xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml
DataContext = {Binding RelativeSource = {RelativeSource Self}}
Title =Some Game DataHeight =216Width =435ScrollViewer.CanContentScroll =TrueScrollViewer.HorizontalScrollBarVisibility =VisibleWindowStartupLocation =CenterScreen的WindowState = 最大化 >
< StackPanel ScrollViewer.HorizontalScrollBarVisibility =VisibleScrollViewer.CanContentScroll =True>
< ListView ItemsSource ={Binding GameCollection}ScrollViewer.HorizontalScrollBarVisibility =VisibleScrollViewer.VerticalScrollBarVisibility =VisibleHeight =75>
< ListView.View>
< GridView>
< GridViewColumn Width =140Header =Game Name
DisplayMemberBinding ={Binding GameName}/>
< GridViewColumn Width =140Header =Creator
DisplayMemberBinding ={Binding Creator}/>
< GridViewColumn Width =140Header =Publisher
DisplayMemberBinding ={Binding Publisher}/>
< / GridView>
< /ListView.View>
< / ListView>
< Button HorizontalAlignment =RightMargin =5,5,5,5
Content =Add RowClick =AddRow_Click/>
< / StackPanel>
< / Window>
但是当列表包含更多行时没有滚动条比可见。谷歌搜索这似乎对许多人来说这也是一个困难的主题。希望有人可以告诉我我错过了什么。
编辑:添加了scrollviewer但仍然没有滚动条。
< Window x:Class =AnalyzeSMlogs.ListViewTest
xmlns =http://schemas.microsoft.com/winfx/2006/ xaml / presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml
DataContext ={Binding RelativeSource = {RelativeSource Self}}
Title =Some Game DataHeight =216Width =435ScrollViewer.CanContentScroll =TrueScrollViewer.HorizontalScrollBarVisibility =VisibleWindowStartupLocation =CenterScreenWindowState =MaximizedVerticalContentAlignment =Stretch>
< StackPanel ScrollViewer.HorizontalScrollBarVisibility =VisibleScrollViewer.CanContentScroll =True>
< ScrollViewer CanContentScroll =TrueVerticalContentAlignment =Stretch>
< ListView ItemsSource ={Binding GameCollection}ScrollViewer.HorizontalScrollBarVisibility =AutoScrollViewer.VerticalScrollBarVisibility =VisibleHeight =autoVerticalContentAlignment =Stretch>
< ListView.View>
< GridView>
< GridViewColumn Width =140Header =Game Name
DisplayMemberBinding ={Binding GameName}/>
< GridViewColumn Width =140Header =Creator
DisplayMemberBinding ={Binding Creator}/>
< GridViewColumn Width =140Header =Publisher
DisplayMemberBinding ={Binding Publisher}/>
< / GridView>
< /ListView.View>
< / ListView>
< / ScrollViewer>
< / StackPanel>
< / Window>
解决方案
你需要把
GridView
inGrid
< window x: class = AnalyzeSMlogs.ListViewTest xmlns:x = < span class =code-string> #unknown >
xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x = http://schemas.microsoft.com/winfx/2006/xaml
Title = 某些游戏数据 WindowStartupLocation = CenterScreen WindowState = 最大化 >
< grid>
< listview itemssource = {Binding GameCollection} >
< listview.view>
< gridview>
< gridviewcolumn width = 140 header = 游戏名称 >
DisplayMemberBinding = {Binding GameName} />
< gridviewcolumn width = 140 header = 创建者 >
DisplayMemberBinding = {Binding Creator} />
< gridviewcolumn width = 140 header = 发布商 >
DisplayMemberBinding = {Binding Publisher} />
< / gridviewcolumn > < / gridviewcolumn > < / gridviewcolumn > < / gridview >
< / listview.view >
< / listview >
< / grid >
< / window >
I have this window
<Window x:Class="AnalyzeSMlogs.ListViewTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Some Game Data" Height="216" Width="435" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible" WindowStartupLocation="CenterScreen" WindowState="Maximized">
<StackPanel ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True">
<ListView ItemsSource="{Binding GameCollection}" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" Height="75">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Game Name"
DisplayMemberBinding="{Binding GameName}" />
<GridViewColumn Width="140" Header="Creator"
DisplayMemberBinding="{Binding Creator}" />
<GridViewColumn Width="140" Header="Publisher"
DisplayMemberBinding="{Binding Publisher}" />
</GridView>
</ListView.View>
</ListView>
<Button HorizontalAlignment="Right" Margin="5,5,5,5"
Content="Add Row" Click="AddRow_Click" />
</StackPanel>
</Window>
But there is no scrollbar when list contains more rows than is visible. Googling this seems that this is a difficult subject for many and me too. Hope someone can tell me what I am missing.
EDIT: added scrollviewer but still no scrollbar.
<Window x:Class="AnalyzeSMlogs.ListViewTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Some Game Data" Height="216" Width="435" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible" WindowStartupLocation="CenterScreen" WindowState="Maximized" VerticalContentAlignment="Stretch">
<StackPanel ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True">
<ScrollViewer CanContentScroll="True" VerticalContentAlignment="Stretch">
<ListView ItemsSource="{Binding GameCollection}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible" Height="auto" VerticalContentAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn Width="140" Header="Game Name"
DisplayMemberBinding="{Binding GameName}" />
<GridViewColumn Width="140" Header="Creator"
DisplayMemberBinding="{Binding Creator}" />
<GridViewColumn Width="140" Header="Publisher"
DisplayMemberBinding="{Binding Publisher}" />
</GridView>
</ListView.View>
</ListView>
</ScrollViewer>
</StackPanel>
</Window>
解决方案
You need to put the
GridView
inside aGrid
<window x:class="AnalyzeSMlogs.ListViewTest" xmlns:x="#unknown"> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Some Game Data" WindowStartupLocation="CenterScreen" WindowState="Maximized" > <grid> <listview itemssource="{Binding GameCollection}"> <listview.view> <gridview> <gridviewcolumn width="140" header="Game Name"> DisplayMemberBinding="{Binding GameName}" /> <gridviewcolumn width="140" header="Creator"> DisplayMemberBinding="{Binding Creator}" /> <gridviewcolumn width="140" header="Publisher"> DisplayMemberBinding="{Binding Publisher}" /> </gridviewcolumn></gridviewcolumn></gridviewcolumn></gridview> </listview.view> </listview> </grid> </window>
这篇关于列表视图上没有滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文