Open AndreasReitberger opened 2 years ago
@StephaneDelcroix thoughts?
Any news on this @PureWeen @StephaneDelcroix ? Is this a bug or some problems of my nuget project? Thank you!
Still seeing this issues. Also with other maui libraries. Any news on this? @PureWeen @StephaneDelcroix
@PureWeen @StephaneDelcroix any news on this?
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.
I'm not sure, but try reordering the resources. https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/resource-dictionaries?view=net-maui-7.0#merge-resource-dictionaries-from-other-assemblies
The resources contained in the resource dictionaries that were merged via the MergedDictionaries collection, in the reverse order they are listed in the MergedDictionaries property.
Order like this works for me and overrides resources from default theme:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<themes:DefaultTheme />
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
But in general, I think the problem is with the IDE, not MAUI
Hi @HavenDV
Thanks for the example. If I reorder the ResourceDictionary
in my DefaultTheme
, there is no change of the described behaviour.
All Red
stuff should be actually Purple
However, if I remove the DefaultColors.xaml
from the DefaultTheme.xaml
and move it directly to the App.Resources
and keep the order you suggest, it works on my end.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<themes:DefaultTheme />
<ResourceDictionary Source="/Themes/DefaultColors.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
But Intelisense
still doesn't find the keys of the Styles
, however the IDE marks keys with are wrong / not available.
It only doesn't suggest it while typing.
Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0. Can repro on android platform with sample project. SharedMauiXamlStyles-main.zip
As far as I know, this has been an issue in Xamarin and is still an issue in MAUI.
We’ve created an library that we want to reuse for all of our apps that are in production. This library has resources like icons, sizes, animations etc. All of theese resources can be StaticResources, but because of this bug, the developers get no intellisense. Which is no good!
We’ve taken advantage of MarkupExtensions for each resource type, and mapped a dictionary of resources with keys to enum values. Heres our icons API:
And here is how our developers use it: https://github.com/DIPSAS/DIPS.Mobile.UI/wiki/Icons
We’ve done it this way for both Xamarin and MAUI, which feels weird, but at the same time it works. 👍🏻🤷♂️
Any news on this?
Description
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.
This is the main app.
The DefaultTheme (from the app) merges the shared styles.
And this the styles coming from the library.
With adding the project directly.
Added as nuget:
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.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/AndreasReitberger/SharedMauiXamlStyles
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows
Affected platform versions
All
Did you find any workaround?
Add as project to the app project and link to it.
Relevant log output
No response