信息
您所需的主题如下所示。但此主题未包含在此库中。

PasswordBox.CaretBrush 属性

2013/12/13

获取或设置用于呈现指示插入点的竖线的画笔。

Namespace:  System.Windows.Controls
程序集:  System.Windows(位于 System.Windows.dll 中)
XMLNS for XAML: 未映射到 xmlns。

public Brush CaretBrush { get; set; }
<PasswordBox>
  <PasswordBox.CaretBrush>
    singleBrush
  </PasswordBox.CaretBrush>
</PasswordBox>
<PasswordBox CaretBrush="colorString"/>

XAML 值

singleBrush

PasswordBox.CaretBrush 的打开和关闭属性元素中,只有一个对象元素用于派生自 Brush 的对象。 该对象元素通常是下列 Windows Phone 类之一: LinearGradientBrushRadialGradientBrushImageBrushSolidColorBrushVideoBrush

colorString

SolidColorBrushColor,表示为特性字符串。 这可以是一个指定的颜色、一个 RGB 值或者一个 ScRGB 值。 RGBScRGB 还可以指定 alpha 信息。 请参见 Color

属性值

类型: System.Windows.Media.Brush
用于呈现指示插入点的竖线的画笔。

以下示例使用 XAML、C# 和 Visual Basic 为 PasswordBox 设置 CaretBrush 属性。

安全说明安全说明:

避免对源代码中的密码进行硬编码。


<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


Windows Phone OS

受以下版本支持: 8.0, 7.1, 7.0

Windows Phone

显示: