Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,
can we write onRender method for a XAML canvas?

i want to draw some shapes, images on a canvas.
i have taken a canvas from Xaml, Now how can i write OnRender method for the canvas.

or we have to create a custom class inheriting from canvas then only we can write onRender method?

Plz help me out


Thanks.
Posted

1 solution

Not an expert in WPF, but you'd normally derive a class from Canvas and override the OnRender method. That's just basic OO, because its no longer just a canvas, it's a canvas with some extra functionality.
 
Share this answer
 
Comments
KiranBabu M 16-Nov-11 5:54am    
so,
we cannot override a OnRender method for a canvas which is added from Xaml.
Rob Philpott 16-Nov-11 5:58am    
You can't override it because that can only be done in child classes. You may be able to hook an event or something.

Simple enough, derive a simple class from Canvas, add your rendering logic, then replace the Canvas in your XAML with your new type.

Is there a reason you want to use graphics primitives rather than the basic graphics elements?
Sergey Alexandrovich Kryukov 16-Nov-11 5:59am    
Sorry, why would you answer on something which you have no idea about, and you did not even bother to check with MSDN? This is not how it works; and there is no such or similar method. Sorry, but please don't confuse people with such posts. I just had to vote 1, sorry.
--SA
Rob Philpott 16-Nov-11 6:10am    
You're an arrogant individual aren't you? Please explain what is wrong with what I'm suggesting.
Sergey Alexandrovich Kryukov 16-Nov-11 7:14am    
No, that's not it. I apologize: I posted complete gibberish, sorry.
I'll remove my post and vote 5 for yours.

Please understand: if I was right and you really written unresponsive message, my notes would not like arrogant. I just was completely wrong. I must be more careful.

Sorry,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900