gpt4 book ai didi

.net - 如何隐藏 WPF ListView 的 header ?

转载 作者:行者123 更新时间:2023-12-03 05:05:24 25 4
gpt4 key购买 nike

我希望能够隐藏 WPF ListView 中每个网格列顶部的标题。

这是我的 ListView 的 XAML:

   <Window x:Class="ListViewTest.Test0.ListViewTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Empty ListView Grid" Height="216" Width="435" FlowDirection="LeftToRight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.IsSharedSizeScope="False">
<Window.Resources>
<XmlDataProvider x:Key="CustomersDS" Source="C:\data.xml"/>
</Window.Resources>


<ListView Margin="0,0,0,50" ItemTemplate="{DynamicResource CustomerTemplate}" ItemsSource="{Binding Source={StaticResource CustomersDS}, XPath=/Customers/Customer}">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Code}"/>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Name}"/>
<GridViewColumn DisplayMemberBinding="{Binding XPath=Country}"/>
</GridView>
</ListView.View>
</ListView>


</Window>

我将其绑定(bind)到的数据是:

 <Customers>
<Customer>
<Code>1234</Code>
<Name>EPI</Name>
<Country>Sesame Street</Country>
</Customer>
<Customer>
<Code>3234</Code>
<Name>Paul</Name>
<Country>United Kingdom</Country>
</Customer>
<Customer>
<Code>3344</Code>
<Name>Juan</Name>
<Country>Spain</Country>
</Customer>
<Customer>
<Code>4321</Code>
<Name>Dodo</Name>
<Country>Mars</Country>
</Customer>
</Customers>

最佳答案

像这样定义样式

<Window.Resources>
....
<Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</Window.Resources>

像这样应用

<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}">
....
</GridView>

关于.net - 如何隐藏 WPF ListView 的 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/632519/

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