2

我有一个简单的 switch 子句,它应该显示/隐藏一些控件并调用一个方法。很简单。问题是什么都没有发生。我是一名 Web 开发人员,并且是 WPF 的新手。这就是为什么我不明白为什么以下不起作用:

switch (_state)
{
    case "ask":
        LabelAsk.Visibility = System.Windows.Visibility.Visible; //not working
        LabelSync.Visibility = System.Windows.Visibility.Hidden; //not working
        ButtonYes.Visibility = System.Windows.Visibility.Visible; //not working
        ButtonNo.Visibility = System.Windows.Visibility.Visible; //not working
        break;
    case "sync":
        LabelAsk.Visibility = System.Windows.Visibility.Hidden; //not working
        LabelSync.Visibility = System.Windows.Visibility.Visible; //not working
        ButtonYes.Visibility = System.Windows.Visibility.Hidden; //not working
        ButtonNo.Visibility = System.Windows.Visibility.Hidden; //not working
        ScanFolders();
        this.Close();
        break;
}
4

0 回答 0