-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for x:Array extension, including inline syntax #28
base: master
Are you sure you want to change the base?
Conversation
There is active proposal in WinUI repo to introduce new arrays syntax in XAML. It can cover cases with inline arrays. |
That looks interesting! I don't think it would solve my problem though, which is passing an array to a markup extension. For example, if there were 2 constructors, In markup extensions particularly, the constructor is resolved from the exact parameter types of the values, so the type of The closest scenario with the proposal would be |
|
||
foreach (var child in ni.Children) | ||
{ | ||
if (child is XamlAstXamlPropertyValueNode propertyNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to trigger an error for unhandled nodes, otherwise they will be silently ignored.
src/XamlX/Ast/Intrinsics.cs
Outdated
} | ||
} | ||
|
||
public XamlILNodeEmitResult Emit(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current policy is to have a separate emitter class rather then implementing IXamlAstEmitableNode. That's needed because of the planned C++ emitter backend for UWP.
Can I continue this PR? |
@workgroupengineering we are positive on supporting x:Array as an XML syntax, just like in WPF. So yes, you can. |
Changes
x:Array
extension, including inline syntax.Use cases
x:Array
as in WPF isn't really useful I believe, as it can be easily replaced by list property setters. My main interest is the inline syntax (which doesn't exist in WPF), example:Passing constant data
Markup extensions (including multibindings)
For example, if
MultiBinding
(in Avalonia) was a markup extension it could be possibly used like this:I also investigated the possibility of handling
params
parameters, but that would be much more work, and this syntax is already considerably more readable in my opinion.