我想删除datagrid中文本下的行。该应用程序的屏幕截图是here。
<DataGrid Name="ProductKeyTable" AutoGenerateColumns="FALSE" IsReadOnly="True"
Grid.Row="2" Margin="15" GridLinesVisibility="Horizontal">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding ID}" Visibility="Collapsed"></DataGridTextColumn>
<DataGridTextColumn Header="Product Key" Binding="{Binding ProductKeyStr}" Width="3*">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="TextBlock.VerticalAlignment" Value="Center" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Generation Date" Binding="{Binding GenerationDate}" Width="3*">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="TextBlock.VerticalAlignment" Value="Center" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Current Machines" Binding="{Binding CurrentMachines}" Width="3*">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="TextBlock.VerticalAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0 0 0 0" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<DataGridTemplateColumn Width="80">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Margin="2" Background="SkyBlue" Foreground="White" FontSize="12" BorderThickness="0 0 0 0" Width="50" Height="30" Click="DeleteProductKeyClick">Delete</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
我尝试将单元格的边框粗细设置为0,但它什么也没做。
删除VerticalContentAlignment属性将起作用,但文本不居中。
有什么想法吗?感谢。