PasswordBox.SelectionForeground Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the brush used for the selected text in the PasswordBox.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<PasswordBox> <PasswordBox.SelectionForeground> singleBrush </PasswordBox.SelectionForeground> </PasswordBox>
<PasswordBox SelectionForeground="colorString"/>
XAML Values
Property Value
Type: System.Windows.Media.BrushThe brush used for the selected text in the PasswordBox.
Dependency property identifier field: SelectionForegroundProperty
Use the SelectionForeground property to change the foreground of the selected password in a password box control.
The following code snippet shows how you can use the SelectionForeground property to set the foreground of the selected password in a PasswordBox. This example is part of a larger example available in the PasswordBox class overview.
Security Note: |
|---|
Avoid hard-coding a password within your source code. |
<TextBlock Text="Demonstrating styles for PasswordBox" Margin="20,10,0,0" /> <TextBlock FontSize="18" Margin="20,10,0,0" TextWrapping="Wrap"> Select the following password to view the results of setting the SelectionForeground and SelectionBackground properties. </TextBlock> <PasswordBox Margin="20,10,0,0" Password="HelloWorld" Width="200" Height="70" SelectionForeground="Black" HorizontalAlignment="Left"> <PasswordBox.SelectionBackground> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="Gray" Offset="0.0" /> <GradientStop Color="White" Offset="1.0" /> </LinearGradientBrush> </PasswordBox.SelectionBackground> </PasswordBox>
Security Note: