有人真的使用 ThumbnailAttribute 作为 Toolbox 图标吗?

发布于 2024-08-20 13:13:58 字数 716 浏览 4 评论 0原文

我正在对新的 WPF/Silverlight 自定义控件进行最后的修饰,并决定这次我将遵循 .NET 3.5 SP1 要求(针对 WPF 版本)。因此,我决定采用推荐的新方法来设置工具箱图标/图像 ThumbnailAttribute。花了一些时间后我无法让它工作并转向谷歌寻求帮助。

令人惊讶的是,搜索 ThumbnailAttribute 在 Google 上基本上不会产生任何结果。有该类的 MSDN 文档、一些不相关的点击和 2 篇文章(其中一篇是我的),展示了如何使用旧方法进行操作,并仅提到 ThumbnailAttribute 有一种新方法。

所以,我的问题是:有人使用 ThumbnailAttribute 为 WPF/Silverlight 控件设置工具箱图像吗?有效吗?

更新: Microsoft 建议使用专门命名的图标文件,而不是按照 Michael S. Scherotter 的规定使用 ThumbnailAttribute(请参阅下面的评论)。

I was putting finishing touches on a new WPF/Silverlight custom control and decided that this time I would go with .NET 3.5 SP1 requirement (for WPF version). So, I decided to go with recommended new way of setting toolbox icon/image with ThumbnailAttribute. After spending some time on it I couldn't make it work and turned for help to Google.

Surprisingly a search for ThumbnailAttribute produces basically no results on Google. There's MSDN documentation of the class, a few irrelevant hits and 2 articles (one of which is mine) showing how to do it the old way and just mentioning that there's a new way with ThumbnailAttribute.

So, my question is this: does anybody use ThumbnailAttribute to set toolbox images for WPF/Silverlight controls? Does it work?

Update: Microsoft recommends using specifically named icon files rather than ThumbnailAttribute as per Michael S. Scherotter (see comment below).

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

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

发布评论

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

评论(1

虫児飞 2024-08-27 13:13:58

您想要为您的类创建一个设计时程序集。这样做是为了将设计时属性分配给不占用程序集中空间的类。这对于 Silverlight 应用程序非常重要,因为它们应该具有更小的程序集以加快下载速度。
请参阅本文 有关设计时装配的说明。

对于图标,在设计时程序集中添加 12x12 和 24x24 PNG 图标作为嵌入资源,其名称如下:

  • Namespace.ControlName.12x12.png
  • Namespace.ControlName.24x24.png

You want to create a design-time assembly for your class. You do this to assign design-time attributes to a class that don't take up space in the assembly. This is important for Silverlight apps which should have smaller assemblyies for faster downloading.
See this article for an description of the design-time assembly.

For Icons, in the design-time assembly add 12x12 and 24x24 PNG icons as embedded resources with these names:

  • Namespace.ControlName.12x12.png
  • Namespace.ControlName.24x24.png
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文