Set different size or auto-resize for Path in StaticResource Canvas

.net, c#, canvas, wpf, xaml

Solution

I'm thinking you could put the `Canvas` inside of a `<ViewBox>` so that it automatically scales down.

Problem

I'm using a `ResourceDictionary` for all my icons like this: ``` <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas x:Key="Icon.Refresh" Width="32" Height="32" Clip="F1 M 0,0L 32,0L 32,32L 0,32L 0,0"> <Path Width="28" Height="28" Canvas.Left="2" Canvas.Top="2" Stretch="Fill" Data="..." /> </Canvas> </ResourceDictionary> ``` And actual XAML: ``` <Button Content="{StaticResource Icon.Refresh}" Height="40" Width="40" /> ``` This works fine as most of my Buttons are this size. But when I want to use it on smaller Buttons it overflows the button: ``` <Button Content="{StaticResource Icon.Refresh}" Height="30" Width="30" /> ``` Is there a way to set the Size of a `StaticResource` or any other clever thing to do?

Original source