public class CMProp : DependencyObject { public static readonly DependencyProperty ControlModeProperty; static CMProp() { FrameworkPropertyMetadata fm = new FrameworkPropertyMetadata(); fm.Inherits = true; fm.DefaultValue = ControlMode.Display; ControlModeProperty = DependencyProperty.RegisterAttached("ControlMode", typeof(LLControls.ControlMode), typeof(CMProp), fm); } public static void SetControlMode(UIElement element, LLControls.ControlMode value) { element.SetValue(ControlModeProperty, value); } public static LLControls.ControlMode GetControlMode(UIElement element) { return (LLControls.ControlMode)element.GetValue(ControlModeProperty); } }ControlMode is an enum with three values: Display, HeaderEdit and DataEdit. I am using the dependency property on a sub-classed canvas:
public static readonly DependencyProperty ControlModeProperty; static LLCanvas() { FrameworkPropertyMetadata p5 = new FrameworkPropertyMetadata(); p5.Inherits = true; ControlModeProperty = CMProp.ControlModeProperty.AddOwner(typeof(LLCanvas), p5); }In use these canvases can be nested so, for example: