0
我想在app.xaml
內設置DataGrid樣式。我嘗試添加樣式,但是我不確定添加單元格和行樣式所需的語義。DataGrid行和單元格樣式在XAML
這就是我到目前爲止所嘗試過的;
<Style TargetType="DataGrid" x:Name="noighlightRowDataGrid">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Background"
Value="White" />
<Setter Property="Foreground"
Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="BorderBrush"
Value="Blue" />
<Setter Property="BorderThickness" Value="2" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
我可以看到丟棄DataGrid.CellStyle
到DataGrid中風格都不會工作,但正如我所說的,我如何正確地創建樣式不確定。
那麼,如果你想你的風格將自動使用你要刪除的X:名稱 –
@ Med.Amine.Touil我不希望它被自動應用,只有那些我指定的風格就是這個。 – CBreeze
您必須爲新創建的樣式指定一個鍵x:Key =「xxxx」 –