本文介绍了如何隐藏一个ListView WPF的头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够隐藏标题在每个网格列的一个WPF的ListView顶部。
这是XAML为我的ListView:
<窗口x:类=ListViewTest.Test0.ListViewTest 的xmlns =http://schemas.microsoft/winfx/2006/xaml/$p$psentation 的xmlns:X =http://schemas.microsoft/winfx/2006/xaml 标题=空的ListView网格高度=216宽度=435的FlowDirection =LeftToRight的HorizontalAlignment =拉伸VerticalAlignment =拉伸Grid.IsSharedSizeScope =FALSE> < Window.Resources> < XmlDataProvider X:关键=CustomersDS来源=C:\ data.xml的/> < /Window.Resources> < ListView的保证金=0,0,0,50的ItemTemplate ={DynamicResource CustomerTemplate}的ItemsSource ={绑定源= {的StaticResource CustomersDS},XPath的= /客户/顾客}> < ListView.View> < GridView控件> < GridViewColumn DisplayMemberBinding ={结合的XPath = code}/> < GridViewColumn DisplayMemberBinding ={结合的XPath =名}/> < GridViewColumn DisplayMemberBinding ={结合的XPath =国家}/> < / GridView的> < /ListView.View> < / ListView控件> < /窗>
我结合这数据是:
<客户> <客户> < code> 1234< / code取代; <名称>&EPI LT; /名称> <国家>芝麻街< /国家> < /客户> <客户> < code> 3234< / code取代; <名称>保罗和LT; /名称> <国家>英国< /国家> < /客户> <客户> < code> 3344< / code取代; <名称>&娟LT; /名称> <国家>西班牙< /国家> < /客户> <客户> < code> 4321< / code取代; <名称>&突突LT; /名称> <国家>火星< /国家> < /客户> < /客户>解决方案
定义一个样式像这样
< Window.Resources> .... <风格X:关键=myHeaderStyle的TargetType ={X:类型GridViewColumnHeader}> < setter属性=能见度VALUE =折叠/> < /样式和GT; < /Window.Resources>
应用它像这样
< GridView的ColumnHeaderContainerStyle ={的StaticResource myHeaderStyle}> .... < / GridView的>I want to be able to hide the header at the top of each grid column in a WPF ListView.
This is the XAML for my ListView:
<Window x:Class="ListViewTest.Test0.ListViewTest" xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/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>The data I am binding this to is:
<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>解决方案
Define a Style like so
<Window.Resources> .... <Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="Visibility" Value="Collapsed" /> </Style> </Window.Resources>Apply it like so
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle}"> .... </GridView>
更多推荐
如何隐藏一个ListView WPF的头?
发布评论