PasswordBox.CaretBrush 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 that is used to render the vertical bar that indicates the insertion point.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<PasswordBox> <PasswordBox.CaretBrush> singleBrush </PasswordBox.CaretBrush> </PasswordBox>
<PasswordBox CaretBrush="colorString"/>
XAML Values
Property Value
Type: System.Windows.Media.BrushThe brush that is used to render the vertical bar that indicates the insertion point.
The following example set the CaretBrush property for a PasswordBox in XAML, C#, and Visual Basic.
Security Note: |
|---|
Avoid hard-coding a password within your source code. |
<StackPanel> <!--Setting the Caret to blue color--> <PasswordBox CaretBrush="Blue" Password="HelloWorld" /> <!--Setting the Caret to red color--> <PasswordBox CaretBrush="Red" Password="HelloWorld" /> </StackPanel>
public void AddPWB() { PasswordBox MyPW1 = new PasswordBox(); MyPW1.Password = "HelloWorld"; //Setting the color of the caret in the first password box to blue SolidColorBrush MyBrush1 = new SolidColorBrush(); MyBrush1.Color = Colors.Blue; MyPW1.CaretBrush = MyBrush1; PasswordBox MyPW2 = new PasswordBox(); MyPW2.Password = "HelloWorld"; //Setting the color of the caret in the second password box to red SolidColorBrush MyBrush2 = new SolidColorBrush(); MyBrush2.Color = Colors.Red; MyPW2.CaretBrush = MyBrush2; MySP.Children.Add(MyPW1); MySP.Children.Add(MyPW2); }
Public Sub AddPWB() Dim MyPW1 As PasswordBox = New PasswordBox MyPW1.Password = "HelloWorld" 'Setting the color of the caret in the first password box to blue Dim MyBrush1 As SolidColorBrush = New SolidColorBrush MyBrush1.Color = Colors.Blue MyPW1.CaretBrush = MyBrush1 Dim MyPW2 As PasswordBox = New PasswordBox MyPW2.Password = "HelloWorld" 'Setting the color of the caret in the second password box to red Dim MyBrush2 As SolidColorBrush = New SolidColorBrush MyBrush2.Color = Colors.Red MyPW2.CaretBrush = MyBrush2 MySP.Children.Add(MyPW1) MySP.Children.Add(MyPW2) End Sub
Show:
Security Note: