I am creating an application which will later go to the Play Store. The application is well-organised and tidy - and utilises the MVVM pattern.
In my application - I have a folder titled 'Styles' which contains numerous styles for different elements of my application:
As you can see I have a ResourceDictionary for a floating action button:
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:FAB="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
xmlns:rsvpapp="clr-namespace:RSVPApp"
x:Class="RSVPApp.Styles.FloatingActionButton">
<Color x:Key="FAB_BlueNormalStyleColor">
#0BA1D8
</Color>
<Color x:Key="FAB_BlueRippleStyleColor">
#21B7ED
</Color>
<Color x:Key="FAB_BluePressedStyleColor">
#3DCBFF
</Color>
<Color x:Key="FAB_RedNormalStyleColor">
#CF0000
</Color>
<Color x:Key="FAB_RedRippleStyleColor">
#ED2121
</Color>
<Color x:Key="FAB_RedPressedStyleColor">
#FF3D3D
</Color>
<Color x:Key="FAB_OrangeNormalStyleColor">
#FFA500
</Color>
<Color x:Key="FAB_OrangeRippleStyleColor">
#EDA621
</Color>
<Color x:Key="FAB_OrangePressedStyleColor">
#FFBB3D
</Color>
<Color x:Key="FAB_GreenNormalStyleColor">
#00E500
</Color>
<Color x:Key="FAB_GreenRippleStyleColor">
#69FA69
</Color>
<Color x:Key="FAB_GreenPressedStyleColor">
#85FF85
</Color>
<!--Blue-->
<Style x:Key="FAB_BlueRegularStyle"
TargetType="FAB:FloatingActionButtonView">
<Setter Property="ImageName"
Value="ic_add_white.png" />
<Setter Property="ColorNormal"
Value="{StaticResource FAB_BlueNormalStyleColor}" />
<Setter Property="ColorRipple"
Value="{StaticResource FAB_BlueRippleStyleColor}" />
<Setter Property="ColorPressed"
Value="{StaticResource FAB_BluePressedStyleColor}" />
<Setter Property="HasShadow"
Value="True" />
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style x:Key="FAB_BlueMiniStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_BlueRegularStyle}">
<Setter Property="Size"
Value="Mini" />
</Style>
<!--Red-->
<Style x:Key="FAB_RedRegularStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_BlueRegularStyle}">
<Setter Property="ColorNormal"
Value="{StaticResource FAB_RedNormalStyleColor}" />
<Setter Property="ColorRipple"
Value="{StaticResource FAB_RedRippleStyleColor}" />
<Setter Property="ColorPressed"
Value="{StaticResource FAB_RedPressedStyleColor}" />
</Style>
<Style x:Key="FAB_RedMiniStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_RedRegularStyle}">
<Setter Property="Size"
Value="Mini" />
</Style>
<!--Orange-->
<Style x:Key="FAB_OrangeRegularStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_BlueRegularStyle}">
<Setter Property="ColorNormal"
Value="{StaticResource FAB_OrangeNormalStyleColor}" />
<Setter Property="ColorRipple"
Value="{StaticResource FAB_OrangeRippleStyleColor}" />
<Setter Property="ColorPressed"
Value="{StaticResource FAB_OrangePressedStyleColor}" />
</Style>
<Style x:Key="FAB_OrangeMiniStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_OrangeRegularStyle}">
<Setter Property="Size"
Value="Mini" />
</Style>
<!--Green-->
<Style x:Key="FAB_GreenRegularStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_BlueRegularStyle}">
<Setter Property="ColorNormal"
Value="{StaticResource FAB_GreenNormalStyleColor}" />
<Setter Property="ColorRipple"
Value="{StaticResource FAB_GreenRippleStyleColor}" />
<Setter Property="ColorPressed"
Value="{StaticResource FAB_GreenPressedStyleColor}" />
</Style>
<Style x:Key="FAB_GreenMiniStyle"
TargetType="FAB:FloatingActionButtonView"
BasedOn="{StaticResource FAB_GreenRegularStyle}">
<Setter Property="Size"
Value="Mini" />
</Style>
</ResourceDictionary>
Now - I want to merge all of my resource dictionaries into my app.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:styles="clr-namespace:RSVPApp.Styles"
x:Class="RSVPApp.App">
<!--
Define global resources and styles here, that apply to all pages in your app.
-->
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<styles:FloatingActionButton />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<Color x:Key="Primary">#2196F3</Color>
<Style TargetType="Button">
<Setter Property="TextColor" Value="White"></Setter>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="#332196F3" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
As you can see - at the top I have declared a merged dictionaries attribute and inside I have the appropriate resource dictionaries.
In one of my pages - I decided that I would want to test whether the styles are detected:
<fab:FloatingActionButtonView Style="{StaticResource FAB_BlueRegularStyle}"/>
Whenever I build the application - it immediately crashes because it cannot detect the style.
Maybe I am doing something wrong? I am not entirely sure. I am looking for a solution to this.
Thank you,






