TextBox.SelectionBackground Property
Silverlight
Gets or sets the brush that fills the background of the selected text.
Namespace: System.Windows.Controls
Assembly: System.Windows (in System.Windows.dll)
<TextBox> <TextBox.SelectionBackground> singleBrush </TextBox.SelectionBackground> </TextBox>
<TextBox SelectionBackground="colorString"/>
XAML Values
Property Value
Type: System.Windows.Media.BrushThe brush that fills the background of the selected text.
Dependency property identifier field: SelectionBackgroundProperty.
Use the SelectionBackground property to change the background of the selected text in the text box control.
The following code snippet shows how you can use the SelectionBackground property to set the background of the selected text in a TextBox. This example is part of a larger example available in the TextBox class overview.
<TextBlock Margin="20,40,0,0" Text="Demonstrating styles for TextBox" /> <TextBlock Margin="20,0,0,0" FontSize="11"> Select the following text to view the results of SelectionForeground and SelectionBackground properties. </TextBlock> <TextBox Text="Styles" Margin="20,5,0,0" HorizontalAlignment="Left" Width="200" Height="35" FontFamily="Arial" FontSize="15" Foreground="White" Background="Black" BorderBrush="White" SelectionForeground="Black"> <TextBox.SelectionBackground> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Gray" Offset="0.0" /> <GradientStop Color="White" Offset="1.0" /> </LinearGradientBrush> </TextBox.SelectionBackground> </TextBox>
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.