AathifMahir / MauiIcons

MauiIcons is Icon Collection Library for .Net Maui
MIT License
196 stars 13 forks source link

Cannot resolve type "http://www.aathifmahir.com/dotnet/2022/maui/icons:Material" #81

Closed BeepBeepBopBop closed 8 months ago

BeepBeepBopBop commented 8 months ago

Hi, I found your library and I liked it a lot but unfortunately I did not manage to use it even after downloading the sample app... Not sure what I'm doing wrong but I get the following error:

Cannot resolve type "http://www.aathifmahir.com/dotnet/2022/maui/icons:Material"

Here is my XAML code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:mi="http://www.aathifmahir.com/dotnet/2022/maui/icons"
             x:Class="MauiApp5.MainPage">

    <ScrollView>
        <mi:MauiIcon Icon="{mi:Material Icon=AirplanemodeActive}"/>
    </ScrollView>

</ContentPage>

And my MauiProgram:

using MauiIcons.Material;
using Microsoft.Extensions.Logging;

namespace MauiApp5
{
    public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .UseMaterialMauiIcons()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                });

#if DEBUG
            builder.Logging.AddDebug();
#endif

            return builder.Build();
        }
    }
}

I have installed all the packages, and I tried a MAUI app with version .NET 7 and 8... The sample works fine though so surely I must be missing something ? Thanks a lot for any suggestion

AathifMahir commented 8 months ago

@BeepBeepBopBop This is an issue with Maui XamlC Compilor itself, When it comes Maui icon you can use the workaround that mentioned in the docs https://github.com/AathifMahir/MauiIcons?tab=readme-ov-file#workaround

public MainPage()
    {
        InitializeComponent();
        // Temporary Workaround for url styled namespace in xaml
        _ = new MauiIcon();
    }
BeepBeepBopBop commented 8 months ago

Oh my bad I did not catch that in the readme... Thanks for getting back to me so quickly, happy new year :)