2014-01-06 57 views

回答

2

这为我工作:

<DataGrid.RowDetailsTemplate> 
<DataTemplate> 
    <Border> 
    <Border.Style> 
    <Style TargetType="Border"> 
     <Style.Triggers> 
     <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True"> 
     <Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}"/> 
     </DataTrigger> 
    </Style.Triggers> 
    </Style> 
    </Border.Style> 
    <StackPanel> 
    <!-- my details content here --> 
    </StackPanel> 
    </Border> 
</DataTemplate> 
</DataGrid.RowDetailsTemplate> 
0

你可以做到这一点的一种方法是设置RowHeaderWidth。这是最左边的一行,当你点击它选择整行时,也应该显示RowDetails。

另一种选择是在数据网格上设置SelectionUnit =“FullRow”,它不会让用户选择单个单元格,而是选择整行,并在每次点击行的任何位置时显示详细信息。

+0

不是我故意的。我希望整个区域(行+细节)突出显示,而不是单元格(默认情况下)。在某种程度上,我认为当选择相关行时应该可以触发细节部分的背景变化。 –

相关问题