.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
I had a working project using the that was not using the CommunityToolkit.
It built and ran fine.
I added the CommunityToolkit
and now the build throws this error:
"Input string was not in the correct format"
It points to line 1 of the mainpage.xaml file.
Regression
No response
Steps to reproduce
.net 8
Maui project
VS 2022
Fairly simple app that retrieves information from a web service and formats it on the device.
Ensure it works without the toolkit.
Add the toolkit and attempt to build.
I get the error noted above.
Add the following to the main page.
<ContentPage
other stuff...
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
<ContentPage.Behaviors>
<mct:EventToCommandBehavior Command="{Binding AppearingCommand}" EventName="Appearing" />
</ContentPage.Behaviors>
... other xaml
</ContentPage>
<ContentPage.Behaviors>
<mct:EventToCommandBehavior Command="{Binding AppearingCommand}" EventName="Appearing" />
</ContentPage.Behaviors>
Try the build again to get the message telling you to change the startup.
Change the MauiProgram start to include the toolkit:
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
builder.Services.Add... blah blah blah other services
return builder.Build();
}
Build again - get an error telling you you need implement the target method in the viewmodel.cs
Implement it per the instructions here: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/event-to-command-behavior
Build again and get the original error.
Expected behavior
I was trying to implement loading of the data when the app starts, but cannot get past the xml error. So the expected behavior would have been to load the data when the app started.
Screenshots
No response
IDE and version
VS 2022
IDE version
Version 17.9.6
Nuget packages
[ ] CommunityToolkit.Common
[ ] CommunityToolkit.Diagnostics
[ ] CommunityToolkit.HighPerformance
[ ] CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
see the bug description above where I pasted in the references
Additional context
I have to caveat this problem with telling you that is is my first Maui app outside of a class. So, I quite possibly am missing something very basic.
Describe the bug
I had a working project using the that was not using the CommunityToolkit.
It built and ran fine. I added the CommunityToolkit
and now the build throws this error: "Input string was not in the correct format" It points to line 1 of the mainpage.xaml file.
Regression
No response
Steps to reproduce
Expected behavior
I was trying to implement loading of the data when the app starts, but cannot get past the xml error. So the expected behavior would have been to load the data when the app started.
Screenshots
No response
IDE and version
VS 2022
IDE version
Version 17.9.6
Nuget packages
Nuget package version(s)
see the bug description above where I pasted in the references
Additional context
I have to caveat this problem with telling you that is is my first Maui app outside of a class. So, I quite possibly am missing something very basic.
Help us help you
Yes, but only if others can assist