[英]Listbox/listview vertical scrollbar does not show (horizontal yes)
I've a listbox defined in xaml like this: 我在xaml中定义了一个列表框,如下所示:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="21" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="23" />
<ColumnDefinition Width="23" />
<ColumnDefinition Width="23" />
<ColumnDefinition Width="4" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="26" />
<RowDefinition Height="*" />
<RowDefinition Height="4" />
</Grid.RowDefinitions>
<ListBox x:Name="AInLb" Margin="8,6,8,8" BorderBrush="Gray" Grid.Row="1" Grid.ColumnSpan="6" Grid.RowSpan="2" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="IsSelected" Value="{Binding Content.IsSelected, Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListView x:Name="AInfoLv" FontFamily="Khmer UI" Background="White" BorderBrush="{x:Null}" BorderThickness="0" Foreground="Black">
<ListView.View>
<GridView>
<GridViewColumn x:Name="LabelColumn" Header="Label" Width="110" DisplayMemberBinding="{Binding Path=Label}" />
<GridViewColumn x:Name="ValueColumn" Header="Value" Width="140" DisplayMemberBinding="{Binding Path=Value}" />
</GridView>
</ListView.View>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border BorderBrush="Transparent" BorderThickness="1" Background="{TemplateBinding Background}">
<GridViewRowPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Label}" Value="Login">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Label}" Value="Skill(s)">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</ListBox>
The height and width for both listbox and listview are set to auto. 列表框和列表视图的高度和宽度均设置为自动。 When the content exceeded the height and width of the listbox, the horizontal scrollbar works fine, but the vertical scrollbar does not show. 当内容超过列表框的高度和宽度时,水平滚动条可以正常工作,但垂直滚动条不会显示。
Update: Included @Dom's suggestion. 更新:包含@Dom的建议。
Update 2: After Height
limit is set for the listbox
. 更新2:在为listbox
设置Height
限制之后。
The ListView alreas a ScrollViewer. ListView增加了一个ScrollViewer。 You need to enable it: 您需要启用它:
<ListView ScrollViewer.CanContentScroll="True"
Scro
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.