1

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!

Community
  • 1
  • 1
Ailayna Entarria
  • 303
  • 3
  • 16

1 Answers1

4

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

TylerD87
  • 1,588
  • 11
  • 20
  • You made my day! this information is exactly what I was missing in my mind to put it all together thanks, tho one question before I will mark it as answer - does the location of my class.cs in my Assembly(let say will put it into different subfolder) has any matter to XAML or its only wants my respected namespace(s) of my Class? – Ailayna Entarria Jan 07 '14 at 15:34
  • I am not 100% sure as it is the usual practice to put your classes in folders that correspond to your namespace. I would say though that only the namespace would matter, the physical location of the file shouldn't make any difference to the compiler. EDIT: Having done a quick google search(as you should have done) it seems that only the namespace matters. – TylerD87 Jan 07 '14 at 15:44