Getting the inherited inheritance property for distribution

I am having trouble getting the bound property value to propagate through the tree from parent to child in the visual hierarchy. The configuration is as follows:

I have a custom panel that creates an instance of Viewport3D. The panel then processes the child element, added and deleted, to create and add an inherited Visual3D class for each child element.

I am trying to declare an attached AttachedToggle property. I would like this property to be in an external owner class called AttachedToggle, which implements the only IsChecked dependency property attached and allows the parent panel or any of the Visual3D elements for children to change the value and have an instance of other value elements reflect the changes. Neither the panel nor the Visual3D class are inherited from a common base. It can be done?

I can successfully change the value of the parent and child IsChecked instances from the application code using Set / GetValue, but I cannot get the distribution for distribution.

+3
source share
2 answers

, . , :

public static readonly DependencyProperty IsChecked = 
    DependencyProperty.RegisterAttached(
    "IsChecked",
    typeof(Boolean),
    typeof(AttachedToggle),
    new FrameworkPropertyMetadata(false, 
        FrameworkPropertyMetadataOptions.Inherits)
  );

- Inherits. . FrameworkPropertyMetadata ( FrameworkPropertyMetadataOptions - OverridesInheritanceBehavior, ).

+16

, , - :

<Panel a:ToggleSwitch="Binding Path=(a:ToggleSwitch), 
           RelativeSource={RelativeSource Mode=FindAncestor, 
           AncestorType={x:Type Panel}}" />
0

Source: https://habr.com/ru/post/1776293/


All Articles