[英]Convert icon file to XAML
I have several windows icons that I would like to use in an existing WPF application. 我有几个要在现有WPF应用程序中使用的Windows图标。
The application uses XAML DrawingImages that are in a ResourceDictionary. 该应用程序使用ResourceDictionary中的XAML DrawingImages。
Is there a way to convert my windows icon files to a XAML DrawingImage? 有没有一种方法可以将Windows图标文件转换为XAML DrawingImage?
You could directly create a BitmapImage
from an icon file, like 您可以直接从图标文件创建
BitmapImage
,例如
<Window.Resources>
<BitmapImage x:Key="Icon1" UriSource="Icons/Icon1.ico" />
</Window.Resources>
and eg use that as the Source
of an Image control 例如使用它作为图像控件的
Source
<Image Source="{StaticResource Icon1}" />
or as well for a DrawingImage, like 或对DrawingImage也一样
<DrawingImage>
<DrawingImage.Drawing>
<ImageDrawing ImageSource="{StaticResource Icon1}"/>
</DrawingImage.Drawing>
</DrawingImage>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.