1

我正在实现 PropertyChangedEventHandler PropertyChanged,它始终为空。属性字符串是正确的donno这里的问题是我正在使用的代码

public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

public bool _playerGridVisibility ;
        public bool PlayerGridVisibility
        {
            get { return _playerGridVisibility; }
            set
            {
                _playerGridVisibility = value;
                this.OnPropertyChanged(Strings.PlayerGridVisibilityString);
            }

并在 xaml

Visibility="{Binding Path=AdsGridVisibility, Converter={StaticResource VC}}"
        }

所以有人能知道这个问题吗?

4

1 回答 1

4

发生这种情况的一个原因是您的代码不处理原始数据上下文。您可能有两个视图模型副本,并且您可能正在更新未绑定的副本。

于 2010-11-30T00:30:22.560 回答