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 6897039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:07:11+00:00 2026-05-27T07:07:11+00:00

According to MSDN , Silverlight static resources lookup mechanism should: The lookup behavior for

  • 0

According to MSDN, Silverlight static resources lookup mechanism should:

The lookup behavior for a StaticResource starts with the object where the actual usage is applied, and its own Resources property. (…) The lookup sequence then checks the next object tree parent. (…) Otherwise, the lookup behavior advances to the next parent level towards the object tree root, and so on.

That’s pretty straightforward, as it narrows down to simply traversing objects graph until requested resource key is found. One might assume, this would therefore work:

<UserControl x:Class="ResourcesExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ResourcesExample="clr-namespace:ResourcesExample" 
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
  <UserControl.Resources>
    <SolidColorBrush Color="Green" x:Key="GreenBrush"/>
  </UserControl.Resources>
  <Grid x:Name="LayoutRoot">
    <ResourcesExample:Tester />
  </Grid>
</UserControl>

<UserControl x:Class="ResourcesExample.Tester"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
  <Grid x:Name="LayoutRoot">
    <TextBlock Text="Show green!" Foreground="{StaticResource GreenBrush}"/>
  </Grid>
</UserControl>

Well it doesn’t. What I get instead is XamlParseException : Cannot find a Resource with the Name/Key GreenBrush.

Am I missing something obvious here or documentation is incorrect?

  • 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-27T07:07:11+00:00Added an answer on May 27, 2026 at 7:07 am

    That’s because before inserting the child UserControl in the mother UserControl, it has to be fully instantiated, and since it doesn’t know its parent just yet, it doesn’t know about the SolidColorBrush.

    If you put the SolidColorBrush in your Appl.xaml’s Resources section, it will work: App.xaml is loaded at application startup, and any resource you put in there will be globally available.

    That said, you could also expose a InnerTextForeground Dependency Property in the child UserControl, and set it to your local SolidColorBrush resource in the parent UserControl.
    It’s not very difficult but let me know if you have trouble doing so.

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

Sidebar

Related Questions

According to [MSDN: Array usage guidelines]( http://msdn.microsoft.com/en-us/library/k2604h5s(VS.71).aspx) : Array Valued Properties You should use
According to MSDN , Monitor.Wait() : Releases the lock on an object and blocks
According to MSDN in .Net DateTimeFormat.MonthName should contain exactly 13 elements with 12 element
According to MSDN : Parameters must be declared on public non-static fields or properties.
According to msdn it should be in windbase.h but it is not available instead
According to MSDN on DateTime.ToString ToString(s) should always return string in the format of
According to msdn in Silverlight images are hit testable over their image/media display areas,
According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False; is
According this MSDN article HttpApplication .EndRequest can be used to close or dispose of
According to MSDN The return value specifies the result of the message processing; it

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.