Geom dev Geom dev - 8 days ago 4
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?


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

if(login_password.Password == "")