Harry Boy
Harry Boy

Reputation: 4745

Convert icon file to XAML

I have several windows icons that I would like to use in an existing WPF application.

The application uses XAML DrawingImages that are in a ResourceDictionary.

Is there a way to convert my windows icon files to a XAML DrawingImage?

Upvotes: 0

Views: 881

Answers (1)

Clemens
Clemens

Reputation: 128061

You could directly create a BitmapImage from an icon file, like

<Window.Resources>
    <BitmapImage x:Key="Icon1" UriSource="Icons/Icon1.ico" />
</Window.Resources>

and e.g. use that as the Source of an Image control

<Image Source="{StaticResource Icon1}" />

or as well for a DrawingImage, like

<DrawingImage>
    <DrawingImage.Drawing>
        <ImageDrawing ImageSource="{StaticResource Icon1}"/>
    </DrawingImage.Drawing>
</DrawingImage>

Upvotes: 1

Related Questions