C#-在WPF DataGrid中删除右边缘行边框 [英] C# - Removing right edge row border in WPF DataGrid

查看:315
本文介绍了C#-在WPF DataGrid中删除右边缘行边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在WPF GridView中删除最右边的GridLine. 这是一个示例.xaml

I am trying to remove the far right GridLine in a WPF GridView. Here is an example .xaml

<Window x:Class="Pack.ExampleForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Pack"
    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
    Width="400" Height="300">

    <DataGrid Margin="5" AutoGenerateColumns="False" 
        CanUserReorderColumns="False" HeadersVisibility="Column">

        <DataGrid.Columns>
            <DataGridTextColumn Binding="{x:Null}" CanUserResize="False"/>
            <DataGridTextColumn Binding="{Binding Path=Key}" Header="Request Header" Width="*"/>
            <DataGridTextColumn Binding="{Binding Path=Value}" Header="Value" Width="*"/>
        </DataGrid.Columns>

        <local:RequestHeader Key="Subject 1" Value="Body 1" />
        <local:RequestHeader Key="Subject 1" Value="Body 1" />
    </DataGrid>
</Window>

但是,如设计器中所示,它具有最右边的网格线,并用黄色圆圈圈出.

However this has the far right gridline, as show in the designer, circled in yellow.

有什么方法可以删除它并且没有边框,因为它在左侧.如果可能的话,宁愿在.xaml中执行此操作.

Is there any way to remove this and have no border, as it is on the left side. Would prefer to do this in the .xaml if possible.

推荐答案

嗯,这只是偷偷摸摸的解决方法,但是...:)

Hm, it is just sneaky workaround, but... :)

<DataGridTextColumn Binding="{Binding Value}" Width="*">
    <DataGridTextColumn.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="Margin" Value="0,0,-1,0"></Setter>
        </Style>
    </DataGridTextColumn.CellStyle>    
</DataGridTextColumn>

这篇关于C#-在WPF DataGrid中删除右边缘行边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆