gpt4 book ai didi

wpf - 删除 ListView 列中的分隔符 - WPF

转载 作者:行者123 更新时间:2023-12-05 08:28:26 26 4
gpt4 key购买 nike

我创建了下一个 ListView

 <ListView Height="Auto" MaxHeight="300" Margin="5,5,5,0" BorderBrush="Transparent"
ItemsSource="{Binding SelectedFolders}" BorderThickness="0" >
<ListView.View>
<GridView>
<GridViewColumn Header="Folder Name" Width="600">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding FolderName}" FontSize="16" Foreground="Black" Margin="2,2" HorizontalAlignment="Left">
<TextBlock.ToolTip>
<TextBlock Text="{Binding FolderFullPath}"/>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Header="Size" Width="70">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding FolderSize}" FontSize="16" Foreground="Black" Margin="2,2" HorizontalAlignment="Left">
<TextBlock.ToolTip>
<TextBlock Text="{Binding FolderFullPath}"/>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

我试图删除列分隔符但没有成功。这是现在的样子:

ListView

在图片中您可以看到尺寸列线,我怎样才能删除它们?

最佳答案

只需创建您自己的样式 GridViewColumnHeader...

这是一个简单的例子,除了一个 TextBlock 之外什么都没有(当然,没有垂直线):

<Window.Resources>
<Style x:Key="GridHeader" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<TextBlock Text="{TemplateBinding Content}" Padding="5" Width="{TemplateBinding Width}" TextAlignment="Right" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</Window.Resources>

用法:

<ListView Height="Auto" MaxHeight="300" Margin="5,5,5,0" BorderBrush="Transparent"
ItemsSource="{Binding ReferenceCollection}" BorderThickness="0">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource GridHeader}">
....

有关详细信息,请参阅 GridView Column Header Styles and Templates Overview

关于wpf - 删除 ListView 列中的分隔符 - WPF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14333486/

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