Reputation: 9479
Is there something like an "OnPaint" method in Silverlight?
Back when I was writing C++, I found that it was easy to use the OnPaint event to customize the display of a class to the screen?
Is there an equivalent in Silverlight? If I want to do something when a UserControl is displayed on the screen, what method would I override?
I noticed this post: C# WPF OnPaint method alternative? but it seems that in Silverlight, thre is no "OnRender" method for a UserControl class.
Upvotes: 0
Views: 713
Reputation: 9479
It is LayoutUpdated. As in:
...
this.LayoutUpdated += new EventHandler(LayoutUpdated);
}
void LayoutUpdated(object sender, EventArgs e)
{}
Upvotes: 0
Reputation: 93571
OnPaint was a workaround... to allow you to customise the appearance of controls. That was because you did not have much control over the default appearance of any controls in WinForms applications.
With Silverlight that all changes. Every control is now effectively skinned, using templates and styles, and there are few limitations on how you can customise them. There are far too many links so I just grabbed a couple for you.
Get yourself a good book on Silverlight and learn the proper way to work with it (not around it). This one is one of my favorites.
If you have specific things you are trying to do, to the appearance of user controls, best to list those instead and find out the best way to do it the Silverlight way. :)
Upvotes: 2
Reputation: 86718
You haven't specified what you're trying to do. If you just want to know when a frame is being rendered, the CompositionTarget.Rendering
Event will tell you that. If you actually want to draw on the frame being rendered, you cannot do so.
Upvotes: 0