title: Canvas as Image in Button WPF
body: <p>I am in the process of moving all images from our project into a <code>ResourceDictionary</code> to be used across all projects. When using Syncfusion Metro Studio I am able to get the XAML source of the images.</p>
  
  <pre><code>&lt;Viewbox x:Shared="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt;
    &lt;Grid&gt;
      &lt;Grid Name="backgroundGrid" Width="48" Height="48" Visibility="Collapsed" /&gt;
      &lt;Path Data="M0,4.1309996L20.362437,4.1309996C20.038338,4.8125897,19.782439,5.5301299,19.594339,6.2769008L2.1451931,6.2769008 2.1451931,23.445208 30.042807,23.445208 30.042807,20.78887C30.342306,20.81167 30.642406,20.834471 30.949104,20.834471 31.367603,20.834471 31.781102,20.81027 32.188001,20.76737L32.188001,25.590239 20.922435,25.590239 20.922435,27.736771 23.605427,27.736771 23.605427,29.882 8.5839529,29.882 8.5839529,27.736771 11.265565,27.736771 11.265565,25.590239 0,25.590239z M29.967411,3.9921243L29.967411,8.1359167 25.823251,8.1359167 25.823251,10.100034 29.967411,10.100034 29.967411,14.243865 31.931586,14.243865 31.931586,10.100034 36.075645,10.100034 36.075645,8.1359167 31.931586,8.1359167 31.931586,3.9921243z M30.948448,0C35.985142,1.0841802E-08 40.067997,4.0825729 40.067997,9.1171007 40.067997,14.153367 35.985142,18.236 30.948448,18.236 25.912456,18.236 21.830998,14.153367 21.830998,9.1171007 21.830998,4.0825729 25.912456,1.0841802E-08 30.948448,0z" Stretch="Uniform" Fill="#FF666666" Width="26" Height="26" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5"&gt;
        &lt;Path.RenderTransform&gt;
          &lt;TransformGroup&gt;
            &lt;TransformGroup.Children&gt;
              &lt;RotateTransform Angle="0" /&gt;
              &lt;ScaleTransform ScaleX="1" ScaleY="1" /&gt;
            &lt;/TransformGroup.Children&gt;
          &lt;/TransformGroup&gt;
        &lt;/Path.RenderTransform&gt;
      &lt;/Path&gt;
    &lt;/Grid&gt;
  &lt;/Viewbox&gt;
  </code></pre>
  
  <p>The issue here is that I am creating buttons with the image next to my text as follows:</p>
  
  <pre><code>&lt;corecontrols:IdyllicButton Name="btnClose" Height="30"&gt;
      &lt;StackPanel Orientation="Horizontal"&gt;
          &lt;Image Source="/MHA.Modules.PolicyAdmin;component/Images/Cancel.png"/&gt;
          &lt;TextBlock VerticalAlignment="Center" Margin="5,0" Text="Close"/&gt;
      &lt;/StackPanel&gt;
  &lt;/corecontrols:IdyllicButton&gt;
  </code></pre>
  
  <p>But I cannot set my <code>Image.ImageSource</code> to my <code>StaticResource</code> that I have created in a <code>ResourceDictionary</code> as I get the following error:</p>
  
  <blockquote>
    <p>An object of the type "System.Windows.Controls.Viewbox" cannot be
    applied to a property that expects the type
    "System.Windows.Media.ImageSource".</p>
  </blockquote>
  
  <p>I have also tried using a canvas.</p>
  
  <p>Any ideas how to do this?</p>