Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!

like image 319
yanivps Avatar asked Dec 20 '25 06:12

yanivps


1 Answers

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

like image 137
anivas Avatar answered Dec 22 '25 20:12

anivas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!