You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're building custom controls, it is VERY hard to make them AoT compatible, because the control templates can no longer use Binding, and you can't use x:DataType.
Say you have a control that provides a default ItemTemplate, this item template must use x:Bind to work with AoT, but you can't use x:Bind in a resource template.
Trying to do so will give you the following error:
Not using x:DataType will cause the app to crash when publishing trimmed because the datatype isn't preserved and setting the ItemSource will crash (with the unhelpful System.ArgumentException: 'Value does not fall within the expected range.' message on the ItemsSource setter.
Another issue that often is hit is getting access to a sub-property from template binding, that isn't possible. There's really no way to convert this classic binding expression: Text="{Binding SomeProperty.SubProperty, RelativeSource={RelativeSource TemplatedParent}}" since you can't replace it with Text="{TemplateBinding SomeProperty.SubProperty}"
It feels to me that there's a major thing missing from the AoT story when it comes to custom control templating.
And set the x:Class property on Generic.xaml. That gets past the issue of being able to use x:DataType on the data template, however it still doesn't work at runtime. It also has the downside of introducing public classes that really shouldn't be exposed to the end user.
The text was updated successfully, but these errors were encountered:
Describe the bug
If you're building custom controls, it is VERY hard to make them AoT compatible, because the control templates can no longer use Binding, and you can't use x:DataType.
Say you have a control that provides a default ItemTemplate, this item template must use x:Bind to work with AoT, but you can't use x:Bind in a resource template.
Trying to do so will give you the following error:
Not using x:DataType will cause the app to crash when publishing trimmed because the datatype isn't preserved and setting the ItemSource will crash (with the unhelpful
System.ArgumentException: 'Value does not fall within the expected range.'
message on the ItemsSource setter.Another issue that often is hit is getting access to a sub-property from template binding, that isn't possible. There's really no way to convert this classic binding expression:
Text="{Binding SomeProperty.SubProperty, RelativeSource={RelativeSource TemplatedParent}}"
since you can't replace it withText="{TemplateBinding SomeProperty.SubProperty}"
It feels to me that there's a major thing missing from the AoT story when it comes to custom control templating.
Steps to reproduce the bug
WMC1119
xaml compiler error.Themes\Generic.xaml
remove the default item template and include the commented-out{Binding}
based item template.Expected behavior
A way to use x:Bind in control templates that is AoT compatible.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
Windows version
Windows 11 (24H2): Build 26100
Additional context
I also tried adding a codebehind file to Generic.xaml like this:
And set the
x:Class
property onGeneric.xaml
. That gets past the issue of being able to usex:DataType
on the data template, however it still doesn't work at runtime. It also has the downside of introducing public classes that really shouldn't be exposed to the end user.The text was updated successfully, but these errors were encountered: