DependencyObject dep = (DependencyObject)e.OriginalSource;
while ((dep != null) && !(dep is DataGridRow))
{
dep = VisualTreeHelper.GetParent(dep);
}
if (dep != null && dep is DataGridRow)
{
DataGridRow row = (DataGridRow)dep;
row.Height = 35;
}
使用此代码选择行的高度已更改但行内容高度未更改。
答案 0 :(得分:3)
你也可以用风格来做,
<Style x:Key="PrettierDataGridStyle" TargetType="dg:DataGrid">
<Setter Property="CellStyle">
<Setter.Value>
<Style TargetType="dg:DataGridCell">
<Style.Triggers>
<!-- Highlight selected rows -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="height" Value="35"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
</Style>