yanivps
yanivps

Reputation: 2163

WPF - Access a XAML resource in code

I have a class Called Photo what i would really like to do is to create in my XAML a resource for example:

<Window.Resources>
   <local:Photo x:Key="photoKey" x:Name="myPhoto" />
</Window.Resources>

and then access it from code.

Not with FindResource() function!

I want a class member to be created just like when i create

<Button x:Name="myButton" />

Thanks for helpers!!

Upvotes: 3

Views: 8542

Answers (1)

anivas
anivas

Reputation: 6567

You can access it as Resources["photoKey"], but not by name.

Upvotes: 8

Related Questions