If I create a new WinUI 3 desktop project, remove the default button XAML from MainWindow.xaml (and the button click handler from the .cs file), and replace it with:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image Grid.Row="0" Source="Assets/StoreLogo.png" Height="50" Width="50" HorizontalAlignment="Left" Margin="8,0"/>
<TabView Grid.Row="1">
<TabView.TabItems>
<TabViewItem Header="Header1" >
<Page></Page>
</TabViewItem>
<TabViewItem Header="Header2" >
<Page></Page>
</TabViewItem>
<TabViewItem Header="Header3" >
<Page></Page>
</TabViewItem>
</TabView.TabItems>
</TabView>
</Grid>
the program fails on startup. The main window appears briefly and then closes. All the above XAML is doing is creating a grid with two rows, placing one of the default asset images in the first row, and creating a TabView in the second, with no code behind.
If I comment out the image line, it works. If I create a TabView with no TabViewItems, it works. If I create a TabView with 1 TabViewItem, it sometimes works. Turning on mixed mode debugging, the debugger gives the exception info: “Unhandled exception at 0x6AF14742 (Microsoft.ui.xaml.dll)”, with the call stack also referencing combase.dll.
This appears to be some sort of timing problem, but I’m lost as to how to approach fixing it.