Hey Guys,
I'm trying to include my resource dictionary in several android applications because every app should have the same background, labels .. you know what I mean.
What have I tried?
I've had tested if my style and the application work together in the same project. I've created a external .net standardlibrary to centralize it.
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="PrimaryText">#FAFAFA</Color>
<Color x:Key="SecondaryText">#F5F5F5</Color>
<Color x:Key="HintText">#80FFFFFF</Color>
I've add the reference (Styles.dll) to my application
When I want to add my style to (e.g.) my labels I use "StaticResource" and "DynamicResource". When I use StaticResource and run the program it throws "Xamarin.Forms.Xaml.XamlParseException: 'Position 40:20. StaticResource not found for key ErrorTextColor'". When I use DynamicResource the application starts but it doesn't take the style.
In app.xaml I've add the namespace and assembly
<?xml version="1.0" encoding="utf-8" ?>
<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:theme="clr-namespace:Styles;assembly=Styles"
xmlns:prism="clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms"
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<theme:BlackStyleDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</prism:PrismApplication>
After I googled a lot I found out that I actually can use "mergedDictionary" to include it to my project but that doesn't work - also "ResourceDictionary Source="...Path" doesn't work for me.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<theme:BlackStyleDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
My App.xaml has "InitializeComponent();" and I tried to build my library as embedded resource, resource and content.
I spent much time to google but don't find an answer so I need you to resolve it.
What works?
As I mentioned above when I had my style.xaml in my current app everything works fine, so there is no problem with the resourcedirectionary.
If you need more information for the solution feel free to ask for it.
Many thanks in advance,
Esorana