Reputation: 8961
I want to bind the selected Background color of MyDataGrid to another IsSelected Background color so they share the same color. I'm thinking it can be done something like below. How can I do it?
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="{Binding ElementName=OtherDataGrid, Path=??Background??" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
Upvotes: 0
Views: 360
Reputation: 939
You can create a brush in resources and refer that in both the data grids.
Like:
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="{StaticResource selectedCellBackground}" />
</Trigger>
</Style.Triggers>
Upvotes: 1
Reputation: 2417
Another way is to declare a notify property in the view model and bind both colors to it.
Upvotes: 0