当我在ListView.ItemsPanel
中设置WrapPanel
时,右滚动条会丢失(不可见)。并且内容通过鼠标滚轮滚动,当然,通过研究此滚动查看器中的可视树,所有属性都已正确安装。这里可能有什么问题以及为什么他不可见。
<Style TargetType="{x:Type ListView}">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel Background="Transparent" MouseDown="WrapPanel_MouseDown_1"
IsItemsHost="True"
Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollContentPresenter}}}">
</WrapPanel>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Path Fill="{Binding ElementName=tBlock, Path=Foreground}" Width="20" Height="20" Margin="5, 0, 0, 0" Stretch="Uniform" Data="{Binding SmallIcon}" />
<TextBlock Margin="5, 4, 5, 0" x:Name="tBlock" Grid.Column="1" TextWrapping="Wrap" Width="200" Text="{Binding Name}"></TextBlock>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
这是截图:
答案 0 :(得分:0)
将VerticalScrollBarVisibility
和/或HorizontalScrollBarVisibility
设置为所需的值:
<ListView
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.Style>
<Style TargetType="{x:Type ListView}">
// ...
默认情况下, VerticalScrollBarVisibility
为Auto
,我无法复制您的问题。但是,我希望这会有所帮助。