C# - 在WPF DataGrid中删除右边缘行边框

Nic*_*tto 3 c# wpf border wpfdatagrid

我试图在WPF GridView中删除最右边的GridLine.这是一个例子.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>
Run Code Online (Sandbox Code Playgroud)

然而,这有最右边的网格线,如设计师所示,以黄色圈出.

例

有没有办法删除它并没有边框,因为它在左侧.如果可能的话,更愿意在.xaml中这样做.

mon*_*str 13

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

<DataGridTextColumn Binding="{Binding Value}" Width="*">
    <DataGridTextColumn.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="Margin" Value="0,0,-1,0"></Setter>
        </Style>
    </DataGridTextColumn.CellStyle>    
</DataGridTextColumn>
Run Code Online (Sandbox Code Playgroud)