I have a control with two properties. One is a DependencyProperty
, the other is an "alias" to the first one. How do I raise the PropertyChanged
event for the second one (the alias) when the first one is changed.
NOTE: I'm using DependencyObjects
, not INotifyPropertyChanged
(tried that, didn't work because my control is a ListVie
sub-classed)
Something like this.....
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == MyFirstProperty)
{
RaiseAnEvent( MySecondProperty ); /// what is the code that would go here?
}
}
If I were using an INotify I could do like this...
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");
}
}
}
Where can I raise PropertyChanged
events on multiple properties from one setter? I need to be able to do the same thing, only using DependencyProperties
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…