WPF Designer & Custom Dependency Properties
30 May 2014 • Technology, WPF, .NetWe needed a custom WPF layout for a work project so we merrily set about extending Panel and implementing our MeasureOverride and ArrangeOverride methods. However, we had some issues with the designer not responding well to XAML changes for our custom dependency properties. The solution turned out to be simple. Register the property with FrameworkPropertyMetadata instead of PropertyMetadata and set the AffectsArrange and AffectsMeasure flags.
static DependencyProperty MyCustomMarginProperty
= DependencyProperty.Register("MyCustomMargin",
typeof (double),
typeof (MyControl),
new FrameworkPropertyMetadata(default(double))
{
AffectsArrange = true,
AffectsMeasure = true
});