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
I have a WinUI 3 app with a DataTemplateSelector and typed DataTemplates that use x:Bind and x:DataType="MyNamespace.Setting". Everything works perfectly in Debug mode, but in Release mode the app crashes with a NullReferenceException (raised from external code, so I don’t get a clear stack trace).
Steps to reproduce the bug
I have a ListView bound to an ObservableCollection<Setting>.
Inside the ListView.ItemTemplate, I use a <ContentControl ContentTemplateSelector="{StaticResource MySelector}" Content="{x:Bind}" />.
My DataTemplateSelector overrides SelectTemplateCore(object item, DependencyObject container), returning one of two typed data templates:
public enum SettingDataType { String, Number }
public class Setting
{
public string Name { get; set; }
public object Value { get; set; }
public SettingDataType DataType { get; set; }
}
Expected behavior
When using WinUI 3 with typed DataTemplates (x:DataType="models:Setting") and a DataTemplateSelector, the same code and XAML that work in Debug should also run successfully in Release. Specifically:
SelectTemplateCore is called for each item to choose the correct DataTemplate at runtime.
The typed DataTemplate (with x:DataType and x:Bind) should be compiled without errors or missing references in both Debug and Release configurations.
The app should not crash or throw a NullReferenceException when loading the templates in Release.
In other words, the linker and runtime should preserve all necessary types, properties, and references so the UI renders properly without any special build-time or runtime differences between Debug and Release.
Describe the bug
I have a WinUI 3 app with a DataTemplateSelector and typed DataTemplates that use x:Bind and x:DataType="MyNamespace.Setting". Everything works perfectly in Debug mode, but in Release mode the app crashes with a NullReferenceException (raised from external code, so I don’t get a clear stack trace).
Steps to reproduce the bug
ObservableCollection<Setting>
.<ContentControl ContentTemplateSelector="{StaticResource MySelector}" Content="{x:Bind}" />
.Expected behavior
When using WinUI 3 with typed DataTemplates (x:DataType="models:Setting") and a DataTemplateSelector, the same code and XAML that work in Debug should also run successfully in Release. Specifically:
In other words, the linker and runtime should preserve all necessary types, properties, and references so the UI renders properly without any special build-time or runtime differences between Debug and Release.
Screenshots
Running in Debug:
Running in Release:
TestBinding2.zip
NuGet package version
None
Windows version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: