Psymon

Psymon

  • NA
  • 18
  • 7.1k

Add background image to shape?

Sep 26 2011 1:26 PM
Hi

I am able to draw / Drag and drop a sqaure to my canvas which was fairly straight forward

I have defined some properties for this via a merged dictionary in resources and the xaml code for the box is:

  <!-- BoxItem -->
  <Style x:Key="BoxItem" TargetType="Path" BasedOn="{StaticResource BoxItemStyle}" >
        <Setter Property="Data" Value="M 0,0 H 60 V40 H 0 Z">
        </Setter>

    </Style>

  <Style x:Key="Process_DragBox" TargetType="Path" BasedOn="{StaticResource BoxItem}">
    <Setter Property="IsHitTestVisible" Value="true"/>
    <Setter Property="Fill" Value="Transparent"/>
    <Setter Property="Stroke" Value="Transparent"/>
  </Style>
 
 //Removed some xaml to keep it short
 <ItemsControl.Items>
  <Path Style="{StaticResource BoxItem}" ToolTip="BoxItem" Tag="BoxItem">
    <s:DesignerItem.DragThumbTemplate>
    <ControlTemplate>
       <Path Style="{StaticResource Process_DragBox}" Tag="BoxItem"/>
    </ControlTemplate>
  </s:DesignerItem.DragThumbTemplate>
      </Path>
  </ItemsControl.Items>

However i would like to assign an image to the shape is this possible as i cannot seem to achieve this no matter what i do i seem to generate varying errors dependant on where and how i attempt to apply the image to the BoxItem.

Any ideas as this is defeating me at the moment.

Many thanks

Answers (1)