Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Universal App Resource is not found when in Shared folder

This problem is mainly bother some as Visual Studio IDE is telling me that it cant find the resource, but when I build the application I am not having any problem.

In my Visual Studio i have this: enter image description here

Here is an example of my Universal App architecture is as Follows:

Example.windowsPhone

->MainPage.xaml

Example.Share

-> Style.xaml
-> App.Xaml has Style.xaml referenced

Eventhought i have reference DmBlueBrush in my Style Page like this :

 <SolidColorBrush x:Key="DmBlueBrush" Color="{StaticResource DmBlue}" />

In Visual Studio it will tell me that it cant find it, but when I build the application it will find this resource. Have I not reference something correctly for my IDE to work?

I am using Visual Studio 2013 Professional Version 12.0.31101.00 Update 4.

Edit 1:

in App.xaml in Shared i Have:

<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Theme/Styles.xaml"/>
                <ResourceDictionary Source="Theme/Other.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
like image 940
Damien Avatar asked Apr 14 '15 21:04

Damien


1 Answers

Did you link your Resource Dictionary?

Right click Shared Project > Add > New Item > Resource Dictionary

For this example, named it MyStyles.xaml

Then in App.xaml link by

<Application
    x:Class="YOUR_CLASS.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:YOUR_CLASS">
    <Application.Resources>
        <ResourceDictionary Source="MyStyles.xaml"></ResourceDictionary>
    </Application.Resources>
</Application>

example MyStyles.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:YOUR_CLASS">
    <SolidColorBrush x:Key="MyGreen" Color="Green"/>    
</ResourceDictionary>
like image 65
Chubosaurus Software Avatar answered Sep 29 '22 01:09

Chubosaurus Software