How to use SVG Icons in Ribbon?

Ribbon for WPF Forum

Posted 8 months ago by Peter Schregle
Version: 22.1.0
Avatar

How can I use SVG files as icons in the ribbon as opposed to PNG files? Is this directly possible at all or do I need to go through a conversion step and create a PNG bitmap and use this bitmap?

Comments (4)

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

WPF doesn't currently have built-in support for SVG images.  That being said, we've found that this SvgToXaml utility is really handy since it will convert a SVG file to a vector DrawingImage that can be used as a WPF ImageSource.  We recommend using vector images like DrawingImages instead of raster PNG images when possible.


Actipro Software Support

Posted 8 months ago by Peter Schregle
Avatar

Would you have a sample for me, that shows how I can code this in the Actipro Ribbon?

Answer - Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Peter,

You just run the linked (above) SvgToXaml app and pick a .svg file.  It converts that to a DrawingImage.  DrawingImage is an ImageSource like BitmapImage, so you can use it anywhere an ImageSource is, like for ribbon button image properties.

Since DrawingImages can get large XAML-wise, it's probably best to put your DrawingImages as x:Key'ed resources in Application.Resources and then use StaticResource to reference them on ImageSource properties that should use them.


Actipro Software Support

Posted 7 months ago by Peter Schregle
Avatar

Thank you very much, very helpful.

The latest build of this product (v22.1.3) was released 20 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.