我有一个有两个属性的控件。一个是 DependencyProperty
,另一个是第一个的“别名”。当第一个事件被更改时,如何引发第二个事件(别名)的 PropertyChanged
事件。
注意 : 我使用的是 DependencyObjects
,而不是 INotifyPropertyChanged
(试过了,但没有成功,因为我的控件是 ListVie
子类)
像这样的东西..。
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == MyFirstProperty)
{
RaiseAnEvent( MySecondProperty ); /// what is the code that would go here?
}
}
如果我使用 INotify,我可以这样做..。
public string SecondProperty
{
get
{
return this.m_IconPath;
}
}
public string IconPath
{
get
{
return this.m_IconPath;
}
set
{
if (this.m_IconPath != value)
{
this.m_IconPath = value;
this.SendPropertyChanged("IconPath");
this.SendPropertyChanged("SecondProperty");
}
}
}
在哪里可以从一个 setter 引发多个属性上的 PropertyChanged
事件?我需要能够做同样的事情,只使用 DependencyProperties
。