Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Which event to buckle control to Page code?
2 replies. Latest Post by Shunyata Kharg on October 6, 2008.
(0)
Shunyata...
Member
2 points
17 Posts
10-06-2008 12:02 PM |
Hello!
I'm in the process of developing a control which I've derived from UserControl. My control has a canvas which I added at designtime and what needs to be drawn is added to the Children property of the canvas in a method I've called Draw(). All fine so far.
However, in my case, what needs to be drawn will depend on how my control is coded in the constructor of the Page in which my control sits. At the moment, my code looks like this:
public Page(){ InitializeComponent(); this.MyControl.DrawASeriesOfElements = true; this.MyControl.Draw();}
what I want to do is eliminate the call to MyControl.Draw() in the constructor. I understand that there's no OnRender() in Silverlight, but I'm not sure which event I have to get my control to subscribe to make the call to Draw() unnecessary. The ones I have tried (LayoutUpdated and ArrangeOverride) do not produce the same results as calling my Draw() method (obscure errors are thrown in MyControl's code).
Any ideas please? Or will have have to oblige my clients to call my Draw() method everytime they make changes to MyControl?
Many thanks!
sladapter
All-Star
17439 points
3,172 Posts
10-06-2008 12:11 PM |
You can call this.Draw() in your MyControl.Loaded event. So when your control is loaded to a Page, it draws itself.
10-06-2008 12:29 PM |
Hello,
sladapter:You can call this.Draw() in your MyControl.Loaded event. So when your control is loaded to a Page, it draws itself.
Perfect, thank you. That looks like being the one!
Thank you!