.NET MAUI - Styles packed in a MAUI Library are not available for InteliSense after released as nuget

Viewed 65

I created a MAUI library to manage all my XAML styles. When I add the library project to my app project solution, I can access all resources with `{StaticResource ...}. Once I start typing, it gives me results of all available keys.

Once I pack the library as nuget and install it over the Nuget-Manager, this stops working. However the styles do work. Just the suggestion of available keys stopped working.

I did a lot of research, but I couldn't find a solution yet.

SourceCode of library: https://github.com/AndreasReitberger/SharedMauiXamlStyles

This is the main app.

<?xml version = "1.0" encoding = "UTF-8" ?>
<Application
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:AppBasement"
    xmlns:themes="clr-namespace:AppBasement.Themes"
    
    x:Class="AppBasement.App"
    >
    <Application.Resources>
        <!-- All styles combined i a ResoureDictionary -->
        <themes:DefaultTheme />
    </Application.Resources>
</Application>

The DefaultTheme (from the app) merges the shared styles.

<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="AppBasement.Themes.DefaultTheme"
    
    xmlns:shared="clr-namespace:AndreasReitberger.Shared;assembly=SharedMauiXamlStylesLibrary"
    >
    <ResourceDictionary.MergedDictionaries>
        <shared:DefaultTheme/>
        <!-- Override colors -->
        <ResourceDictionary Source="/Themes/DefaultColors.xaml" />
        <!-- Item Templates -->
        <ResourceDictionary Source="/Themes/ItemTemplates/ListViewItemTemplates.xaml" />
        <!-- Additional Control Styles -->
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBusyIndicator.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

And this the styles coming from the library.

<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="AndreasReitberger.Shared.DefaultTheme"
    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="SharedColors.xaml" />
        <ResourceDictionary Source="/Themes/SharedIcons.xaml" />
        <ResourceDictionary Source="/Themes/SharedFonts.xaml" />

        <ResourceDictionary Source="/Themes/Controls/ActivityIndicator.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Border.xaml" />
        <ResourceDictionary Source="/Themes/Controls/BoxView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Button.xaml" />
        <ResourceDictionary Source="/Themes/Controls/CheckBox.xaml" />
        <ResourceDictionary Source="/Themes/Controls/DatePicker.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Editor.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Entry.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Label.xaml" />
        <ResourceDictionary Source="/Themes/Controls/ListView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Page.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Picker.xaml" />
        <ResourceDictionary Source="/Themes/Controls/ProgressBar.xaml" />
        <ResourceDictionary Source="/Themes/Controls/RadioButton.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Grid.xaml" />
        <ResourceDictionary Source="/Themes/Controls/IndicatorView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Frame.xaml" />
        <ResourceDictionary Source="/Themes/Controls/RefreshView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/SearchBar.xaml" />
        <ResourceDictionary Source="/Themes/Controls/SearchHandler.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Shadow.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Shell.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Slider.xaml" />
        <ResourceDictionary Source="/Themes/Controls/StackLayout.xaml" />
        <ResourceDictionary Source="/Themes/Controls/SwipeItem.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Switch.xaml" />
        <ResourceDictionary Source="/Themes/Controls/TimePicker.xaml" />

        <!-- Item Templates -->
        <ResourceDictionary Source="/Themes/ItemTemplates/ListViewItemTemplates.xaml" />
        <!--
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfAutoComplete.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBadgeView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBorder.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBusyIndicator.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfButtons.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfCardView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfCharts.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfCircularProgressBar.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfCircularGauge.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfComboBoxes.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfGradientView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfListView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfMaskedEdit.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfNumericTextInputs.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfNumericUpDowns.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfPicker.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfPullToRefresh.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfRotator.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfRangeSlider.xaml" />
        
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfTextInputLayout.xaml" />
        -->
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBadgeView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfBusyIndicator.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfListView.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfRadialGauge.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfSlider.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfRangeSlider.xaml" />
        <ResourceDictionary Source="/Themes/Controls/Syncfusion/SfTabView.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

With adding the project directly.

image

Added as nuget:

image

I also noticed, that the same Keys does not get overrided. For instance, the shared theme uses "PrimaryColor" as key. This is overriden in the app theme (DefaultColors). However it takes always the color set in the shared library. I already tried to change the position of the directories, however no changes.

What I'm doing wrong here? Any help is appreciated!

0 Answers
Related