Avalonia: Relativesource bindings and syntax.

Created on 11 Jul 2016  路  2Comments  路  Source: AvaloniaUI/Avalonia

We discussed this a bit in chat and came up with a couple of ideas for syntax:

<Foo Bar="{$parent[Window].Baz}" /> would bind to the first ancestor of type Window.
<Foo Bar="{$parent[Grid, 2].Baz}" /> would bind to the second ancestor of type Grid. Not sure how useful this is.
<Foo Bar="{$root.Baz}" /> would bind to the first parent of type Window or userControl

The equivalent WPF syntax is so ugly I don't even want to type it :)

enhancement

Most helpful comment

We'll still need the {Binding} part according to XAML syntax (though I would love to have a similar binding syntax to polymer where e.g. {{Value}} would mean the same as {Binding Value}.

Given that, here are a few more ideas:

  • {Binding $parent.Foo} logical parent
  • {Binding $parent[1].Foo} logical grandparent
  • {Binding $self.Foo} property on self

All 2 comments

We'll still need the {Binding} part according to XAML syntax (though I would love to have a similar binding syntax to polymer where e.g. {{Value}} would mean the same as {Binding Value}.

Given that, here are a few more ideas:

  • {Binding $parent.Foo} logical parent
  • {Binding $parent[1].Foo} logical grandparent
  • {Binding $self.Foo} property on self

I'm going to take a stab at implementing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JonathaN7Shepard picture JonathaN7Shepard  路  4Comments

MiKaMaru picture MiKaMaru  路  4Comments

akunchev picture akunchev  路  3Comments

RUSshy picture RUSshy  路  4Comments

georgiuk picture georgiuk  路  3Comments