是否有类似“OnPaint”的东西? Silverlight 中的方法?

发布于 2024-11-27 11:41:42 字数 343 浏览 1 评论 0原文

Silverlight中有类似“OnPaint”方法的东西吗?

当年我写C++的时候,我发现用OnPaint事件来自定义一个类在屏幕上的显示是不是很简单?

Silverlight中有类似的东西吗?如果我想在屏幕上显示 UserControl 时执行某些操作,我应该重写什么方法?

我注意到这个帖子: C# WPF OnPaint 方法替代方案? 但似乎在 Silverlight 中,UserControl 类没有“OnRender”方法。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

两相知 2024-12-04 11:41:42

OnPaint 是一种解决方法...允许您自定义控件的外观。这是因为您对 WinForms 应用程序中任何控件的默认外观没有太多控制权。

有了 Silverlight,一切都改变了。现在,使用 模板样式,并且对如何自定义它们几乎没有限制。链接太多了,所以我只为您抓了几个。

给自己找一本关于 Silverlight 的好书,并学习使用它的正确方法(而不是围绕它)。 这个是我的最爱之一。

如果您想要执行特定的操作(例如用户控件的外观),最好将这些操作列出来,并找出实现该操作的最佳方法Silverlight 方式。 :)

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

七色彩虹 2024-12-04 11:41:42

您还没有指定您要做什么。如果您只想知道何时渲染帧,则 CompositionTarget.Rendering Event 会告诉您这一点。如果您确实想在正在渲染的帧上绘制,则无法这样做。

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.

清晰传感 2024-12-04 11:41:42

这是布局更新。
如:

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

}

  void LayoutUpdated(object sender, EventArgs e)
{}

It is LayoutUpdated.
As in:

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

}

  void LayoutUpdated(object sender, EventArgs e)
{}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文