Reputation: 48139
This is not the simple "IsSelected" background color of a datagrid row. What I am referring to is when I am in a datagrid, that has editable data, I click in a given cell and have any text (for example an address), if I select part of the text, the HIGHLIGHT coloring is what I want to change... I assume it would be part of the DataGridCell styling, but not sure where.
Upvotes: 2
Views: 1701
Reputation: 69959
You are looking for the TextBoxBase.SelectionBrush
Property. From the linked page on MSDN:
Gets or sets the brush that highlights selected text.
<TextBox SelectionBrush="Red" SelectionOpacity="0.5"
Foreground="Blue" CaretBrush="Blue">
This is some text.
</TextBox>
UPDATE >>>
You can apply this property in a Style
that is applied to the DataGridTextColumn.EditingElementStyle
property, like this:
<DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}">
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="{x:Type TextBox}">
<Setter Property="SelectionBrush" Value="Red" />
</Style>
</DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Upvotes: 4