简体   繁体   中英

Adding class to use in XAML

I am learning about transparency and found some interesting answer for myself at

WPF: Detect Image click only on non-transparent portion

However I do not understand at all the part where it says in answer

after adding this class, just use it like a regular image:

utils:OpaqueClickableImage Name="image" Source="http://entropymine.com/jason/testbed/pngtrans/rgb8_t_bk.png" Stretch="None"

First of all I wrote the class and how do I add it in XAML now, so that it will be usable/visible? And if I may, since I'm a total beginner at this, to explain in step by step if its some thig complicated. Thank you for any kind of help/advice!

OpaqueClickableImage is a class that they have created which inherits from Image.

the "utils" part of the XAML snippet you posted refers to a custom namespace. You would need to add the name space so it would be visible. So if the namespace of your OpaqueClickableImage class was Program.Extensions you would need to add :

xmlns:utils="clr-namespace:Program.Extensions"

to your "Window" markup.

Then your OpaqueClickableImage would be usable just like any other image like this:

<utils:OpaqueClickableImage Source="image.jpg" width="100" height="100" />

Hope this makes sense...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM