1

我有一个 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;
        }
    }

我怎样才能解决这个问题?

4

1 回答 1

1

请实现INotifyPropertyChanged接口

private Visibility _gridVisibility = Visibility.Visible;
public Visibility GridVisibility
{
    get
    {
        return _gridVisibility;
    }
    set
    {
        _gridVisibility = value;
        NotifyPropertyChanged();
    }
}
于 2017-07-12T06:44:26.153 回答