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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:46:54+00:00 2026-05-15T04:46:54+00:00

I understand that calling FindResource() on a FrameworkElement (e.g. a Window) can be used

  • 0

I understand that calling FindResource() on a FrameworkElement (e.g. a Window) can be used to find a resource in the FrameworkElement’s ResourceDictionary.

For example, I’ve used it many times to access a Style through code to add a new Setter to the Style dynamically. I always pass the x:Key value of the Style as a string into the FindResource() method. Like… Style style = w.FindResource("GridDescriptionColumn") as Style;

My question is, I noticed that FindResource() accepts an argument of type object and not an argument of type string. I can’t for the life of my think of a reason I would call FindResource() with an argument that is not a string. It makes me think that I may unaware of other ways to use FindResource().

Does anyone know why FindResource() accepts a parameter type of object and not string? If so, what would be an example of calling FindResource() with a parameter type other than a string?

Thanks.

  • 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-15T04:46:55+00:00Added an answer on May 15, 2026 at 4:46 am

    A resource can have any object as a key. Adding a resource with an object key in code behind is easy and can be useful. In XAML, most of the time you’re using a string as the x:Key. However there’s a common case where the key is not a string and you might even have used without realizing it:

    When a Style has no x:Key, it’s applied to every instance of its TargetType. But there’s an implicit key added by the compiler: the type of the TargetType itself.

    In short, writing <Style TargetType="{x:Type Button}" /> in a resources section is exactly the same as writing <Style TargetType="{x:Type Button}" x:Key="{x:Type Button}" />. To get this resource back from code, you have to use FindResource(typeof(Button)), passing a Type and not a string.

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

Sidebar

Related Questions

I understand that calling Thread.Abort() is BAD AND WRONG because of various reasons Can
I understand that callable's call can throw the exception to the parent method calling
I understand that applications under the same domain name can talk to each other
I understand that we can set the various style attributes from code behind using
I understand that with javascript you can select the contents of a textbox with
I understand that collections like the Hashtable are synchronized, but can someone explain to
When should retain be used ? I understand that it increments the object references
I am quiet new to javascript, can not understand that why all javascript calls
I was given to understand that calling print obj would call obj.__str__() which would
I understand that $something->function(); is calling a function within a class but what does

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.