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

  • Home
  • SEARCH
  • 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 7863647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:32:55+00:00 2026-06-02T23:32:55+00:00

I’m currently getting to grips with WPF resources and wondering if you can help

  • 0

I’m currently getting to grips with WPF resources and wondering if you can help me:

I have a WPF window which contains its own resources. It also contains a content control which changes its content depending on what is selected in a tree view, e.g.:

contentControl1.Content = someUserControl;

This can be a UserControl e.g. SomeUserControl which uses a static resource which I have defined in the window xaml.

When creating an instance of SomeUserControl in the window code behind, I get an XMLParseException (‘Provide value on ‘System.Windows.StaticResourceExtension’ threw an exception.’). This is on the line containing the binding to the static resource.

To solve this, I added this to the constructor of SomeUserControl (parentResources being the window’s resources from where someUserControl is instantiated):

public SomeUserControl(ResourceDictionary parentResources)
{
    this.Resources.MergedDictionaries.Add(parentResources);
    InitializeComponent();
}

Is this the best approach for finding resources in this particular case? Thanks for any help.

  • 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-06-02T23:32:56+00:00Added an answer on June 2, 2026 at 11:32 pm

    I assume you have a {StaticResource myResource}. Have you tried using {DynamicResource myResource}?

    See http://msdn.microsoft.com/en-us/library/ms748942.aspx

    EDIT

    Ok, given that you’re resource is a converter, which cannot use a dynamic resource, then I think what you’re doing is probably as a good a solution as any.

    The underlying issue is that at the moment that your control is instantiated, it is not a part of the Window and so it doesn’t have any access to the Window’s resources. And as the term static in StaticResource implies, the control expects that the resource is going to be available. So you have to make it available when the control is instantiated.

    You might also want to look at something like Prism and it’s Region’s which might be a better way to handle swapping out your “controls” (depending on your needs).

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

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.