开发者

Is there something like an "OnPaint" method in Silverlight?

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.


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


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.


It is LayoutUpdated. As in:

...
            this.LayoutUpdated += new EventHandler(LayoutUpdated);

}

  void LayoutUpdated(object sender, EventArgs e)
{}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜