Geom dev Geom dev - 6 months ago 85
C# Question

Check if password field is empty

In my XAML I have:

<PasswordBox PlaceholderText="Password" Name="login_password" Width="350" />

Am trying to check if the
is empty via:

if(login_password.Text == "") //this returns an error
//show message box

How can I check if the
is empty?

Answer Source

The PasswordBox has the Password property. So you should check for Password property instead of Text:

if(login_password.Password == "")