PropertyChangedEventHandler PropertyChanged 为 null

发布于 2024-09-16 17:02:44 字数 930 浏览 2 评论 0原文

我正在实现 PropertyChangedEventHandler PropertyChanged 并且它始终为空。 属性字符串是对的不知道问题出在哪里 这是我正在使用的代码

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}}"
        }

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

i am implementing PropertyChangedEventHandler PropertyChanged and it's always null.
property string is right donno where is the problem
here is the code i am using

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);
            }

and in the xaml

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

so can anyone knows the problem ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-09-23 17:02:44

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

One reason this could be happening is if your code does not deal with the original data context. You might have two copies of the view model and you might be updating the one that is not bound.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文