Click or drag to resize

RelativeSource

A RelativeSource obtains an element based on its relation to the element for which RelativeSource is defined.

Example
                  <
                  Button IsVisible="{Binding Path=CurrentElement.IsClickable, Source={RelativeSource AncestorType=Container, AncestorLevel=2}}" />
Parameters
  • Mode (default) : RelativeSourceMode

    The kind of relationship the searched element has to the current element.

    Allowed values:

    • FindAncestor (default)
    • Self

    Self makes RelativeSource return the element for which RelativeSource is defined. FindAncestor looks for a parent element of the specified type and level.

  • AncestorType : string

    Type of parent element to look for.

  • AncestorLevel : int

    Level of parent to look for. Can be combined with the AncestorType parameter.

    Example
    {RelativeSource AncestorType=Container, AncestorLevel=2}}

    In the example above, we look for a second parent of type Container.