New to Telerik UI for WPF? Download free 30-day trial

Key Properties

The purpose of this help article is to show you the key properties of RadPasswordBox control. The topic includes the following properties:

SecurePassword

SecurePassword is a read-only property that returns the current password as a System.Security.SecureString.

SecurePassword is not a dependency property (it is not bindable) due to security reasons.

Password

Password property returns the current password as a string representation. It could be used to set initial password as demonstrated in Example 1.

Example 1: Setting initial Password

<telerik:RadPasswordBox Width="150" Password="defaultpassword" /> 

Figure 1 illustates RadPasswordBox when loaded.

Figure 1: RadPasswordBox with Password set

WPF RadPasswordBox RadPasswordBox with Password set

Password is not a dependency property (it is not bindable) as dependency properties keep their values unencrypted in memory.

When the password is preserved in the Password property, it is actually saved in the process memory as plain text. In certain cases, you could choose not to use that property (check SecureString vs. String).

IsPasswordVisible

IsPasswordVisible is a read-only property indicating whether the password is currently visible.

PasswordChar

PasswordChar property defines the masking character used to hide the actual password. The default value is bullet character (●). Example 2 demonstrates how it could be set.

Example 2: Setting PasswordChar

<telerik:RadPasswordBox Width="150" PasswordChar="*"/> 

Figure 2: RadPasswordBox with PasswordChar set

WPF RadPasswordBox RadPasswordBox with PasswordChar set

ShowPasswordButton Settings

ShowPasswordButton refers to the button used to display the entered password at runtime. RadPasswordBox provides the following settings regarding the ShowPasswordButton.

When the password is displayed through the ShowPasswordButton, it is preserved in the process memory as plain text. In some cases, you could choose to remove that button through the ShowPasswordButtonVisibility property.

ShowPasswordButtonVisibility

ShowPasswordButtonVisibility property defines the visibility mode of the ShowPassword button. It is of ShowPasswordButtonVisibilityMode enum type and could receive the following values:

  • Never
  • Always
  • Auto (the button will be visible only when the password is entered).

The default value is Auto.

To completely remove the ShowPasswordButton, you could set this property to Never as demonstrated in Example 3.

Example 3: Setting ShowPasswordButtonVisibility

<telerik:RadPasswordBox Width="150" ShowPasswordButtonVisibility="Never" /> 

Figure 3: RadPasswordBox with ShowPasswordButtonVisibility set

WPF RadPasswordBox RadPasswordBox with ShowPasswordButtonVisibility set

ShowPasswordButtonContent / ShowPasswordButtonContentTemplate

ShowPasswordButtonContent and ShowPasswordButtonContentTemplate identify the content and respectively the template for presenting that content of the ShowPassword button. The next example demonstrates how these properties could be used in order to represent the ShowPassword button with an Image.

First, we will create a simple DataTemplate as demonstrated in Example 4.

Example 4: Adding ImageTemplate

<DataTemplate x:Key="ImageTemplate"> 
    <Image Source="{Binding}" Stretch="None" /> 
</DataTemplate> 

Example 5 illustates how to set the ImageTemplate to the ShowPasswordButtonContentTemplate property of RadPasswordBox as well as define its ShowPasswordButtonContent property.

Example 5: Setting ShowPasswordButton content properties

<telerik:RadPasswordBox Width="150" ShowPasswordButtonContent="star.png" ShowPasswordButtonContentTemplate="{StaticResource ImageTemplate}" /> 

Figure 4: RadPasswordBox with ShowPasswordButton content properties applied

WPF RadPasswordBox RadPasswordBox with ShowPasswordButton content properties applied

Watermark Settings

WatermarkContent / WatermarkTemplate

WatermarkContent and WatermarkTemplate identify the content and respectively the template for presenting that content of the Watermark inside RadPasswordBox. The next example illustates how you could use WatermarkTemplate property in order to apply a Watermark with an Image.

First, we will create a simple DataTemplate as demonstrated in Example 6.

Example 6: Adding WatermarkWithImageTemplate

<DataTemplate x:Key="WatermarkWithImageTemplate"> 
    <StackPanel Orientation="Horizontal"> 
        <Image Source="passwordImage.png" Width="14" Height="14" /> 
        <TextBlock Text="Enter password" /> 
    </StackPanel>            
</DataTemplate> 

Then, set the defined WatermarkWithImageTemplate to the WatermarkTemplate of the RadPasswordBox.

Example 7: Setting WatermarkTemplate

<telerik:RadPasswordBox Width="150"  WatermarkTemplate="{StaticResource WatermarkWithImageTemplate}" /> 

Figure 5 shows the result.

Figure 5: RadPasswordBox with WatermarkTemplate applied

WPF RadPasswordBox RadPasswordBox with WatermarkTemplate applied

WatermarkBehavior

WatermarkBehavior is an enum property which defines when the Watermark content of RadPasswordBox will be hidden. It could receive the following values:

  • HiddenWhenFocused
  • HideOnClick
  • HideOnTextEntered

The default value is HideOnTextEntered.

See Also

In this article