I tried to make a demo application with this Uno Platform template.
All I wanted to do is add winui2 with this example and add the Windows Community Toolkit with this example.
When doing the things mentioned in the tutorial for the Windows Community Toolkit, which is to install the following Nuget package:
and use the following reference in my XAML:
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
In the XAML-file I added the following code-snipped provided by the tutorial:
<controls:DataGrid x:Name="dataGrid">
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Header="Rank"/>
<controls:DataGridComboBoxColumn Header="Mountain"/>
</controls:DataGrid.Columns>
</controls:DataGrid>
Leading me to the following XAML-file in my Shell.xaml:
<ContentControl
x:Class="AndroidTest.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AndroidTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prismMvvm="using:Prism.Mvvm"
xmlns:prismRegions="using:Prism.Regions"
xmlns:winui="using:Microsoft.UI.Xaml.Controls"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
prismMvvm:ViewModelLocator.AutowireViewModel="True"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="20">
<TextBlock Text="{Binding Title}" FontSize="30" />
<TextBlock Text="Welcome to Uno/WinUI and Prism!" FontSize="15" />
<!-- winui -->
<winui:NumberBox />
<!-- community toolkit -->
<controls:DataGrid x:Name="dataGrid">
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Header="Rank"/>
<controls:DataGridComboBoxColumn Header="Mountain"/>
</controls:DataGrid.Columns>
</controls:DataGrid>
</StackPanel>
<ContentControl Grid.Row="1" prismRegions:RegionManager.RegionName="ContentRegion" />
</Grid>
</ContentControl>
Now the code works fine for UWP, but it does not work with Android anymore. I get this error message in App.xaml.cs
:
Prism.Ioc.ContainerResolutionException: 'An unexpected error occurred while resolving 'AndroidTest.Views.Shell''
At the function:
protected override UIElement CreateShell()
{
return Container.Resolve<Shell>();
}
And the following output:
Loaded assembly: /data/user/0/AndroidTest.AndroidTest/files/.__override__/System.ComponentModel.DataAnnotations.dll [External]
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.TextBlock] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.TextBox] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.Control] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.FrameworkElement] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.Border] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.ScrollViewer] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[est.AndroidTes] Accessing hidden method Landroid/view/View;->initializeScrollbars(Landroid/content/res/TypedArray;)V (greylist, JNI, allowed)
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.Grid] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.Button] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[est.AndroidTes] Explicit concurrent copying GC freed 90(37KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 2487KB/3316KB, paused 289us total 3.144ms
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.ContentPresenter] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Windows.UI.Xaml.Controls.Primitives.RepeatButton] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[0:] The Bindable attribute is missing and the type [Microsoft.UI.Xaml.Controls.NumberBox] is not known by the MetadataProvider. Reflection was used instead of the binding engine and generated static metadata. Add the Bindable attribute to prevent this message and performance issues.
[monodroid-assembly] open_from_bundles: failed to load assembly en-US/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly en/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.resources.dll
**Prism.Ioc.ContainerResolutionException:** 'An unexpected error occurred while resolving 'AndroidTest.Views.Shell''
Any ideas of what I am missing?
It turned out to be a problem with different versions of NuGet packages and problems with their dependencies.
For a functioning app with Uno Platform, Prism Library and the Windows Community Toolkit you need the following versions:
When installing these NuGet packages versions all dependencies are correct and it works fine.