[英]Scroll never appears in ListView
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListView Grid.Row="1" Margin="0" Background="Transparent" ItemsSource="{Binding Path=HistoryList, Mode=OneWay}" Name="leftPanelScrollViewer" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="{Binding Background}" Tag="{Binding Id}" ContextMenuOpening="FrameworkElement_OnContextMenuOpening" ContextMenuClosing="FrameworkElement_OnContextMenuClosing" ContextMenuService.HasDropShadow="True" ContextMenuService.Placement="Bottom" ContextMenuService.PlacementTarget="{Binding ElementName=PersonNameHistoryItem}" Padding="10 80" CornerRadius="3" BorderThickness="0" Margin="5,0,5,5" MouseLeftButtonUp="Item_OnMouseDown">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" VerticalAlignment="Top" Width="44" Height="44" Source="/Size.WPF;component/Assets/default-avatar.png" />
...
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
I have this code in WPF App. 我在WPF应用程序中有此代码。
Problem - scroll never appears. 问题-滚动永远不会出现。 Instead of adding scroll
ListView
make Height bigger. 而不是添加滚动
ListView
使Height更大。
The same with ListBox
. 与
ListBox
相同。
When I don't need scroll it looks like and When I need scroll it looks like 当我不需要把它的滚动的样子 , 当我需要滚动它看起来像
In what wrapped ListBox
: Page
> Grid
( 在包装
ListBox
: Page
> Grid
(
<Grid.RowDefinitions>
<RowDefinition Height="90" />
<RowDefinition Height="780" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
) > Grid
( Grid.RowSpan="3"
)> Border
> Grid
( <RowDefinition Height="*" />
) > ListView
)>
Grid
( Grid.RowSpan="3"
)> Border
> Grid
( <RowDefinition Height="*" />
)> ListView
You've probably got the grid inside a stack panel or some other control that's unbound in size. 您可能已经将网格放在堆栈面板或其他大小不受限制的控件中。
Stack panels grow to what ever size their content needs. 堆叠面板的大小可以满足其内容需求。
You need to either restrict the maximum size of the stack panel or remove it altogether. 您需要限制堆栈面板的最大尺寸或将其完全删除。
Once you've done that the scrollbar should appear. 完成后,滚动条应会出现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.