Reputation: 6471
I want to make a TextBox's Text display like a PasswordBox's Text. Is there any way by which I can do it? I think styling the TextBox may work. I tried to style it using PasswordBox's default style (http://msdn.microsoft.com/en-us/library/dd334412.aspx) but it didn't work.
Upvotes: 0
Views: 2966
Reputation: 1238
You can try this by adding FontFamily
of the TextBox
as following:
<TextBox Text="{Binding YOUR_PROPERTY}"
FontFamily="ms-appx:///Assets/PassDot.ttf#PassDot"
FontSize="35"/>
In my case this worked just fine.
Upvotes: 0
Reputation: 16648
Use an IValueConverter
in wich you replace each character in the Text
variable of your TextBox with a *
, then put the resulting string of stars in the tag property of your TextBox.
This way, your textbox is not showing the actual string edited (which is a password here if i understood you right).
In your binding, put UpdateSourceTrigger="PropertyChanged"
to get it updated on every key instead of on LostFocus. Then bind the text displayed to the TextBox.Tag
property.
Upvotes: 1
Reputation: 19895
There is a PasswordBox in WPF since .Net 3.0 onwards.
http://www.wpftutorial.net/PasswordBox.html
Is this what you are looking for?
Upvotes: 0