Why does FrameworkElement's FindResource() Method Accept an Object and not a String?
Posted
by ChrisNel52
on Stack Overflow
See other posts from Stack Overflow
or by ChrisNel52
Published on 2010-06-08T16:30:46Z
Indexed on
2010/06/08
16:32 UTC
Read the original article
Hit count: 146
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.
© Stack Overflow or respective owner