The value "<" is not valid in the attribute in the PasswordBox control

When creating a WPF application that includes a control PasswordBox, I tried setting PasswordChar'<' instead of '*' to display. I wrote the following code:

<PasswordBox PasswordChar="<"></PasswordBox>

When using this code, the following error is reported:

Error 1 The value "<" is not valid in the attribute.

+4
source share
4 answers

Use this instead:

<PasswordBox PasswordChar="&lt;"></PasswordBox>

You will find an exhaustive list of characters and how to write them in XAML in this MSDN article: XML Character and XAML Objects

+5
source

< - XML. &lt;, :

<PasswordBox PasswordChar="&lt;" />

.

XAML

<PasswordBox x:Name="tbPassword" />

tbPassword.PasswordChar = '<';
+4

'<' is a reserved character, try using this instead:

<PasswordBox PasswordChar="&lt;"></PasswordBox>
+2
source

You will need to use &lt;for <and &gt;for> in xaml:

 <PasswordBox PasswordChar="&lt;"></PasswordBox> 
+1
source

All Articles