1

I need to verify whether an object is visible or not, I tried to write this code, but It doesn't work (NullReferenceException):

if (PasswordConfirm.Visibility != Visibility.Collapsed)
                {
                    labelInsertPassword.Visibility = Visibility.Collapsed;
                    PasswordConfirm.Visibility = Visibility.Collapsed;
                }

How can I do that? Thank you!

4

1 回答 1

3

以下片段在我的情况下工作正常。您需要显示与该代码相关的其他代码以获得良好的解决方案..

  if (passwordBox1.Visibility == Visibility.Visible)
        MessageBox.Show("Visible");
    else
        MessageBox.Show("Not visible");
于 2013-01-14T12:51:25.037 回答