Forum Xamarin Xamarin.Forms

Merging ResourceDictionary from a different Project.

Hello and Thanks for including me in the Xamarin community.


I am performing maintenance on an application using .NETStandard .Library v2.0.3, Xamarin.Forms v3.6.0.220655, Xamarin.Essentials v1.0.1, Visual Studio 2017 v15.9.12.
I am very comfortable with developing apps using Xamarin but very new to merging ResourceDictionaries in Xamarin (which I thought would be similar to WPF merging).

The apps I develop have a very consistent style, and I define the ResourceDictionary for each app separately in the App.xaml in the PCL/Portable/Main Project (I am not sure what to call this since moving over to .NetStandard 2.0).

The Problem: Homemade Bug is present in 20+ apps

We recently found a minor bug that we introduced in a work-around we made years ago, and I face the task of updating this in about 20+ apps.
To avoid this happening again I want to create a "Common" project that can be referenced by multiple Xamarin solutions, and move the problem-page into this "Common" project.

What I want to do: "Common" project for all 20+ apps - then merge ResourceDictionaries

One thing I would like to do is create a ResourceDictionary that is inside this Common project then use it in any app that merges the ResourceDictionary of the Common project.

Is this possible?

I have noticed that the pages I create in this Common can get Styles from the App.xaml, but I want to go in the opposite direction: the app gets the styles from the Common project.

What I have now

I have squashed the Exception where it does not find the ResourceDictionary I wanted to merge.
Now I have get exception that my {StaticResource DefCaptionHeight} cannot be found.

Here is how my Common ResourceDictionary appears in Xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns=""

    <OnPlatform x:Key="DefCaptionTitle" x:TypeArguments="xfc:GridLength" iOS="22" Android="26" WinPhone="22" />

Here is the code-behind for the Common ResourceDictionary:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace XamarinCommon
public partial class XamarinStyles : ResourceDictionary
public XamarinStyles()



Here is where I merge in the App (or should I be merging in every page?):

<Application xmlns=""







Here is the page in the Portable Class where I try to get DefCaptionTitle:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""

        <Grid HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand">

                <RowDefinition Height="{StaticResource DefCaptionTitle}"></RowDefinition>
                <RowDefinition Height="1*"></RowDefinition>                

                <ColumnDefinition Width="1*"></ColumnDefinition>                



Or is it better to abandon this idea and continue defining the ResourceDictionary in the app, then locally defining any specific resources I need for pages that exist in the Common project?

I am unsure why I cannot make the C# code appear normally in a Code-Block:

Sign In or Register to comment.