当属性值更改时向 wpf 控制器添加事件
我有一个属性
public sealed partial class Computer
{
private bool _online;
public bool Online
{
get { return _online; }
set
{
_online = value;
RaiseProperty("Online");
}
}
}
,它引发 INotifyPropertyChanged 类型的事件
public sealed partial class Computer : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void RaiseProperty(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
我的问题是,如何添加一个附加事件,告诉 TabControl 在这种情况下每次在线属性更改时运行特定方法?
I have a property
public sealed partial class Computer
{
private bool _online;
public bool Online
{
get { return _online; }
set
{
_online = value;
RaiseProperty("Online");
}
}
}
Which raises an event of type INotifyPropertyChanged
public sealed partial class Computer : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void RaiseProperty(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
My question is, how can I add an additional event telling in this case an TabControl to run a specific method each time the Online Property changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要向
PropertyChanged
事件注册一个方法You need to register a method to the
PropertyChanged
event您可以像这样使用此事件:
You can use this event like: