Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Relative source syntax sugar #1209
Syntax sugar for RelativeSource bindings. Fixes #590.
You can now use the following shorthand for RelativeSource bindings:
Left a few comments. If you agree, I wonder if maybe we should do this in a couple of separate PRs:
Bindinga markup extension
- Add a
Aside: We can probably simplify things a bit in our code here because any class can be used as a markup extension in XAML (cwensley/Portable.Xaml#65) so we can probably merge a few classes...
I'm a little unsure about switching between logical and visual trees depending on whether a type is specified. For example, I'd expect these two snippets to do the same:
But currently they won't: the first will bind to
Well for the longhand I think we're bound to follow WPF's syntax. The WPF syntax isn't confusing because you always have to supply the control type. But if for the shorthand we're allowing the user to not supply a control type then I think it'd be confusing (and also not that useful) to use the visual tree.
So if that's accepted, then we need to support looking up in both the logical and visual tree.
If we need to support both then still my preferred solution is to supply a
What do you think?
I know its a bit late, however allow me to suggest what I think could be a minor improvement for the syntax...
types could be declared in <> brackets like a generic class in c#?
essentially  is reserved for indexing, and <> is reserved for type selection, might be more memorable than [type;level] could easily forget the order?
Looks good though will give this a test hopefully mon or tuesday