I created a WPF UserControl with a number of DependencyProperty custom properties, which all affect OnMeasure and call PropertyChangedCallback, e.g.:
private static readonly DependencyProperty ArrowStrokeThicknessProperty = DependencyProperty.Register("ArrowStrokeThickness", typeof(double), typeof(ProjectListTreePanel), new FrameworkPropertyMetadata(2d, FrameworkPropertyMetadataOptions.AffectsMeasure, PropertyChangedCallback), ValidateArrowStrokeThickness);
I'd rather put all these properties into a separate DependencyObject:
internal class MyArrowProperties : DependencyObject
{
private static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register("StrokeThickness", typeof(double), typeof(MyArrowProperties), new FrameworkPropertyMetadata(2d, FrameworkPropertyMetadataOptions.AffectsMeasure, PropertyChangedCallback), ValidateStrokeThickness);
...
}
... and have that DependencyObject become a DependencyProperty of my UserControl:
public partial class ProjectListTreePanel : UserControl
{
private static readonly DependencyProperty ArrowProperty = DependencyProperty.Register("Arrow", typeof(MyArrowProperties), typeof(ProjectListTreePanel), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure, PropertyChangedCallback));
Will changes to the properties of the MyArrowProperties DependencyObject be automatically forwarded to the containing ProjectListTreePanel UserControl, so MeasureOverride is getting called on the ProjectListTreePanel UserControl, when, for instance, I update
MyProjectListTreePanel.Arrow.StrokeThickness = 2
?
Or what do I need to do to have changes of encapsulated properties be forwarded to outer containers?
Similarity
The problem described here is similar to the Thickness struct. The Thickness struct is a collection of four distinct values. When any of these values changes, the Thickness struct raises an OnPropertyChanged event.