Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give ResourceDictionary Source in WPF with folder structure

In a WPF application, Resources.xaml(Resource Dictionary) is placed in Resources folder and GetStarted.xaml(UserCOntrol) is placed in Views folder. Wizard.xaml(UserControl) is in the root folder.

Now, in Wizard.xaml:

<ResourceDictionary.MergedDictionaries>
    <ResousrceDictionary Source="Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

works fine.

I'm not sure how to access it In GetStarted.xaml,

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="component/Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

doesn't work.

Please help me. I'm new to WPF.

like image 667
Jeevan Avatar asked Feb 07 '14 00:02

Jeevan


People also ask

How do you add a ResourceDictionary?

In the Solution Explorer, right click the DataPresenter's folder, click Add, and then click New Item… In the Add New Item dialog box, select ResourceDictionary (WPF), and assign it a name matching the style group's name (i.e., DataPresenter, Editors, or Primitives). Click Add.

How do I add resources to XAML dictionary?

Tip You can create a resource dictionary file in Microsoft Visual Studio by using the Add > New Item… > Resource Dictionary option from the Project menu. Here, you define a resource dictionary in a separate XAML file called Dictionary1.

What default resources are supported in WPF?

WPF supports different types of resources. These resources are primarily two types of resources: XAML resources and resource data files. Examples of XAML resources include brushes and styles. Resource data files are non-executable data files that an application needs.


1 Answers

Try AssemblyTitle in your source like below:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/YourProjectAssemblyTitle;component/Resources/Resources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
like image 184
Mukesh Rawat Avatar answered Oct 04 '22 09:10

Mukesh Rawat