gpt4 book ai didi

wpf - 标题未显示在 WPF ListView 中

转载 作者:行者123 更新时间:2023-12-02 01:22:53 25 4
gpt4 key购买 nike

我知道这一定是显而易见的,但我从 WPF 开始,但我陷入了困境:

我有以下 ListView(位于页面主网格的第二行),内容显示,但标题未显示!

<ListView Grid.Row="1" Name="container" ItemsSource="{Binding MyCollection}" >
<ListView.View>
<GridView>
<GridViewColumn Width="50" Header="A" DisplayMemberBinding="{Binding A}"/>
<GridViewColumn Width="50" Header="B" DisplayMemberBinding="{Binding B}"/>
<GridViewColumn Width="50" Header="C" DisplayMemberBinding="{Binding C}"/>
</GridView>
</ListView.View>
</ListView>

感谢任何帮助!

编辑:

感谢 Roel,我能够在资源字典中找到导致此问题的样式:

<Style TargetType="{x:Type ListView}" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ScrollViewer Margin="{TemplateBinding Padding}" VerticalScrollBarVisibility="Visible">
<WrapPanel IsItemsHost="True" MinWidth="100" Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}">
</WrapPanel>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

如何在项目的其余部分保留该样式而不将其应用于此特定 listView?

最佳答案

您可以覆盖该 ListView 的样式。这可能是最简单的方法:

<ListView Grid.Row="1" Name="container" ItemsSource="{Binding MyCollection}"  >
<ListView.Style>
<Style TargetType="{x:Type ListView}"/>
</ListView.Style>

<ListView.View>
<GridView>
<GridViewColumn Width="50" Header="A" DisplayMemberBinding="{Binding A}"/>
<GridViewColumn Width="50" Header="B" DisplayMemberBinding="{Binding B}"/>
<GridViewColumn Width="50" Header="C" DisplayMemberBinding="{Binding C}"/>
</GridView>
</ListView.View>
</ListView>

希望这有帮助!

关于wpf - 标题未显示在 WPF ListView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1238249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com