如何在运行时获取标准WPF控件的工具箱图标?
我尝试了这样的事情:
var attrs = typeof(System.Windows.Controls.ComboBox).GetCustomAttributes(typeof(System.Drawing.ToolboxBitmapAttribute), true);
...但是 attrs 是空集合。我还尝试在程序集中查找图标资源,但什么也没找到。
I tried something like this:
var attrs = typeof(System.Windows.Controls.ComboBox).GetCustomAttributes(typeof(System.Drawing.ToolboxBitmapAttribute), true);
...but attrs is empty collection. I also tried to look up for icons resources in assemblies and nothing found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为 ComboBox 类是实际的运行时类,它没有这样的属性。您需要找到设计时类。我简要浏览了一些 WPF 程序集,但没有找到它。
That's because the ComboBox class is the actual run-time class, which has no such attributes. You'll need to find the design-time class. I've briefly looked through some of the WPF assemblies but couldn't find it.
我猜想WPF标准控件的大部分图标都包含在Visual Studio图像库中:
https://msdn.microsoft.com/en-us/library/ms246582。 ASPX
I guess that most of the icons for WPF standard controls are included in the Visual Studio Image Library:
https://msdn.microsoft.com/en-us/library/ms246582.aspx