NoWar
NoWar

Reputation: 37633

TextBox to PasswordBox in WPF

I have to convert TextBox XAML to PasswordBox XAML. The main problem is <TextBox.Text>.

Any clue how it can be done?

Thank you!

<TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Name="tbxPassword" VerticalAlignment="Top" Width="277">
 <TextBox.Text>
     <Binding Path="Password" Source="{StaticResource ods}"  UpdateSourceTrigger="PropertyChanged" >
      <Binding.ValidationRules>
            <c:ConfigValidationRule />
      </Binding.ValidationRules>
     </Binding>
 </TextBox.Text>
</TextBox>

Upvotes: 0

Views: 1965

Answers (1)

Moble Joseph
Moble Joseph

Reputation: 657

If its really about password, you should use PasswordBox, Binding it to a dependency property would cause security vulnerabilities.

<PasswordBox
 Name="pwdBox" 
 MaxLength="64"
 PasswordChar="#"
 PasswordChanged="PasswordChangedHandler"  
/>

You can see the basic usage here Password Box

Upvotes: 4

Related Questions