单击按钮时的WPF网格可见性

时间:2017-07-12 06:37:19

标签: wpf visibility wpfgrid

我有一个WPF应用程序。如果我只按下按钮上的网格隐藏显示,那么它正在工作。但是如果我在下面编写任何代码,它就无法正常工作。

<Grid Margin="0">
    <Grid x:Name="nonLoading" Margin="0" Visibility="{Binding Path=GridVisibility}">
    </Grid>

                              

private Visibility _gridVisibility = Visibility.Visible;
    public Visibility GridVisibility
    {
        get
        {
            return _gridVisibility;
        }
        set
        {
            _gridVisibility = value;
        }
    }

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

请实施INotifyPropertyChanged界面

private Visibility _gridVisibility = Visibility.Visible;
public Visibility GridVisibility
{
    get
    {
        return _gridVisibility;
    }
    set
    {
        _gridVisibility = value;
        NotifyPropertyChanged();
    }
}