LearnWPF.com posted this article about converting bitmap images to XAML and using them in your applications.
LearnWPF.com发布了这篇关于将位图图像转换为XAML并在应用程序中使用它们的文章。
The outer element of the XAML image is a Canvas
. However, the Window.Icon
property only accepts an ImageSource
object. Does anyone know how I can 'wrap' the Canvas
in an ImageSource
so I can use it as a window icon?
XAML图像的外部元素是Canvas。但是,Window.Icon属性仅接受ImageSource对象。有谁知道如何在ImageSource中“包装”Canvas所以我可以将它用作窗口图标?
Alternatively, is there a better way to use a XAML image as a window icon?
或者,有没有更好的方法将XAML图像用作窗口图标?
1 个解决方案
#1
11
The WPF window Chrome(header bar, Icon etc) are part of the typical Win32 Window system. So it was not built to use with Vector Icon, you need to specify an .Ico, .png or some other supported image file to the Window.Icon property.
WPF窗口Chrome(标题栏,图标等)是典型的Win32 Window系统的一部分。因此它不能与Vector Icon一起使用,您需要为Window.Icon属性指定.Ico,.png或其他一些支持的图像文件。
But if you really want to make a Vector(XAML) animating Icon, you need to think about the concept of Chrome less window. That means gets rid of the old style window chrome(WIndowStyle="None") and build our own chrome entirely with WPF, then you can place your Vector directly over the left top corner and it will just work as you do with any other XAML Visuals in the application.
但是如果你真的想制作一个Vector(XAML)动画图标,你需要考虑Chrome less window的概念。这意味着摆脱旧样式窗口chrome(WIndowStyle =“None”)并使用WPF完全构建我们自己的chrome,然后你可以将你的Vector直接放在左上角,它就像你使用任何其他XAML一样工作应用程序中的视觉效果。
Read more about how to create Chromeless window on bellow links
详细了解如何在波纹管链接上创建Chromeless窗口
- How do I implement a chromeless window with WPF?
- Creating a Custom Window in WPF
如何使用WPF实现无边框窗口?
在WPF中创建自定义窗口
#1
11
The WPF window Chrome(header bar, Icon etc) are part of the typical Win32 Window system. So it was not built to use with Vector Icon, you need to specify an .Ico, .png or some other supported image file to the Window.Icon property.
WPF窗口Chrome(标题栏,图标等)是典型的Win32 Window系统的一部分。因此它不能与Vector Icon一起使用,您需要为Window.Icon属性指定.Ico,.png或其他一些支持的图像文件。
But if you really want to make a Vector(XAML) animating Icon, you need to think about the concept of Chrome less window. That means gets rid of the old style window chrome(WIndowStyle="None") and build our own chrome entirely with WPF, then you can place your Vector directly over the left top corner and it will just work as you do with any other XAML Visuals in the application.
但是如果你真的想制作一个Vector(XAML)动画图标,你需要考虑Chrome less window的概念。这意味着摆脱旧样式窗口chrome(WIndowStyle =“None”)并使用WPF完全构建我们自己的chrome,然后你可以将你的Vector直接放在左上角,它就像你使用任何其他XAML一样工作应用程序中的视觉效果。
Read more about how to create Chromeless window on bellow links
详细了解如何在波纹管链接上创建Chromeless窗口
- How do I implement a chromeless window with WPF?
- Creating a Custom Window in WPF
如何使用WPF实现无边框窗口?
在WPF中创建自定义窗口