When I encapulate a group of DependencyProperties into a DependencyObject, will property changes automatically be forwarded to UserControl?

36 views Asked by At

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.

0

There are 0 answers