Reputation: 4483
I am using DepdendencyObject
s with PropertyChangedCallback
s and I want to detect a subproperty-change inside of this callback. The proplem is that the DependencyPropertyChangedEventArgs
-Object does only let me see the Property that contains the DP
containing the Property that changed. Is there any way to reach this Subproperty?
class MainClass : DepencencyObject
{
public ComplexObject MainProperty
{
get { return (ComplexObject)GetValue(MainPropertyProperty); }
set { SetValue(MainPropertyProperty, value); }
}
public static readonly DependencyProperty MainPropertyProperty =
DependencyProperty.Register("MainProperty",
typeof(ComplexObject), typeof(MainClass),
new PropertyMetadata(new ComplexObject([...])));
private static void MainProperty_PropertyChangedCallback(... DependencyPropertyChangedEventArgs e)
{
// Unable to detect a change, if 'ComplexObject.SubProperty'
// changes; it is shown like a change of 'MainProperty'
}
}
class ComplexObject : DepencencyObject
{
public int SubProperty
{
get { return (int)GetValue(SubPropertyProperty); }
set { SetValue(SubPropertyProperty, value); }
}
public static readonly DependencyProperty SubPropertyProperty =
DependencyProperty.Register("SubProperty",
typeof(int), typeof(ComplexObject),
new PropertyMetadata(0));
}
Someone does
(new MainClass()).MainProperty.SubProperty = 100000;
and the PropertyChangedCallback is called because MainProperty
changed (not SubProperty
).
Upvotes: 0
Views: 358
Reputation: 438
Deriving your ComplexObject
, from Freezable
(and implementing Freezable
) should be enough, or not?
According to MSDN Documentation:
A class that derives from Freezable gains the following features:
Upvotes: 1