Description:
WinUI.TableView v1.5.0-preview1 throws a XamlParseException when the column options/filter flyout is created in a Native AOT WinUI 3 application.
The exception is:
Cannot add instance of type 'Microsoft.UI.Xaml.Controls.MenuFlyoutItem'
to a collection of type
'Windows.Foundation.Collections.IVector`1<Microsoft.UI.Xaml.Controls.MenuFlyoutItemBase>'.
[Line: 0 Position: 0]
This appears to originate from TableViewFilterMenuFlyout.Items, which is declared as IList<MenuFlyoutItemBase>, while TableViewColumnHeader.xaml populates it with derived MenuFlyoutItem and MenuFlyoutSeparator instances. Under CsWinRT/Native AOT, the property is projected as IVector<MenuFlyoutItemBase>, and inserting the derived XAML objects fails during flyout creation.
This is different from the missing menu bindings discussed in #140: v1.5.0-preview1 gets past those binding issues, but the new filter flyout collection itself fails to materialize.
Steps to Reproduce:
-
Create a packaged WinUI 3 application targeting .NET 10.
-
Enable Native AOT:
<PublishAot>true</PublishAot>
-
Reference WinUI.TableView v1.5.0-preview1.
-
Add a TableView with at least one bound column and leave column sorting/filtering enabled.
-
Run the application and open a column header's options/filter menu.
-
Observe the XamlParseException shown above.
A minimal table declaration is sufficient:
<tv:TableView ItemsSource="{x:Bind ViewModel.Items}"
AutoGenerateColumns="False">
<tv:TableView.Columns>
<tv:TableViewTextColumn Header="Name"
Binding="{Binding Name}" />
</tv:TableView.Columns>
</tv:TableView>
Expected behavior:
The column options/filter flyout should open and display its menu items without throwing an exception in a Native AOT application.
Screenshots:
Not applicable. The runtime exception and relevant type information are included above.
Environment:
- Package Version:
1.5.0-preview1
- WinAppSDK Version: host application
2.2.0; also reproduced after aligning the host to the WinAppSDK 1.8 line used by the package
- Target framework:
net10.0-windows10.0.22621.0
- Runtime identifier:
win-x64
- Deployment: packaged MSIX
- Native AOT: enabled
Contribution:
Description:
WinUI.TableViewv1.5.0-preview1 throws aXamlParseExceptionwhen the column options/filter flyout is created in a Native AOT WinUI 3 application.The exception is:
This appears to originate from
TableViewFilterMenuFlyout.Items, which is declared asIList<MenuFlyoutItemBase>, whileTableViewColumnHeader.xamlpopulates it with derivedMenuFlyoutItemandMenuFlyoutSeparatorinstances. Under CsWinRT/Native AOT, the property is projected asIVector<MenuFlyoutItemBase>, and inserting the derived XAML objects fails during flyout creation.This is different from the missing menu bindings discussed in #140: v1.5.0-preview1 gets past those binding issues, but the new filter flyout collection itself fails to materialize.
Steps to Reproduce:
Create a packaged WinUI 3 application targeting .NET 10.
Enable Native AOT:
Reference
WinUI.TableViewv1.5.0-preview1.Add a
TableViewwith at least one bound column and leave column sorting/filtering enabled.Run the application and open a column header's options/filter menu.
Observe the
XamlParseExceptionshown above.A minimal table declaration is sufficient:
Expected behavior:
The column options/filter flyout should open and display its menu items without throwing an exception in a Native AOT application.
Screenshots:
Not applicable. The runtime exception and relevant type information are included above.
Environment:
1.5.0-preview12.2.0; also reproduced after aligning the host to the WinAppSDK 1.8 line used by the packagenet10.0-windows10.0.22621.0win-x64Contribution: