Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:00:55+00:00 2026-05-27T12:00:55+00:00

i am new to WPF so maybe this will be noob question but i

  • 0

i am new to WPF so maybe this will be “noob” question but i can’t find answer to it (and it seems so easy)…

well i am programing WPF app and i want to use smth similar to css for webpages, so i found ResourceDictionary and tried to use it…

I have main window in which i create Frame and on click some UserControl is loaded to that same Frame.I include my ResourceDictionary (root/style/Styles.xaml) to my main window like this:

<Window.Resources>
    <ResourceDictionary x:Key="styles" Source="style/Styles.xaml" />
</Window.Resources>  

in which i have:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="ProductsRequired" TargetType="{x:Type Label}">
    <Setter Property="Height" Value="28" />
    ...

I don’t use it on my main window but want to use it on my UserControls, which are loaded to that main window and i try to use it like this:

<Label Name="product1" Style="{DynamicResource ProductsRequired}"  />

Warning i am getting all the time is: The resource “ProductsRequired” could not be resolved.

I even tried including Styles to my UserControl

<UserControl.Resources>
  <ResourceDictionary x:Key="styles" Source="../style/Styles.xaml" />
</UserControl.Resources>

and nothing happens…

Well my question is long but i wanted to be clear… 🙂

P.S. all that logic works in C# code btw

private ResourceDictionary myStyles = new ResourceDictionary();
Style ProductsRequired = myStyles["ProductsRequired"] as Style;
product1.Style = ProductsRequired;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:00:55+00:00Added an answer on May 27, 2026 at 12:00 pm

    This won’t do, you add a resource dictionary as a resource when you need to add it to the resources, it cannot be accessed like this. You need to add it to the MergedDictionaries (See MSDN for usage examples!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm rather new to WPF, so maybe this is a simple question. I have
I've spent far too much time with this and can't find the mistake. Maybe
I'm quite new to WPF so I'm learning most of this the hard (but
I am new to WPF, so the answer to the following question might be
I will start by saying that I am completely new to WPF. But, I
I apologise if this seems a little basic, but I'm new to WCF -
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
being new to WPF this is a complex problem for me. What i want
I've done a bit of searching on this, but nothing seems to have quite
While designing a new WPF application I noticed exceptions not being thrown during data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.