2010-06-13 33 views
0

我試圖將圖像標籤添加到WPF圖像,我沒有多少運氣。如果可能的話,我想通過數據綁定來完成。我可以使用DataTemplate設置資源來處理此問題嗎?WPF在DataBinding的圖像上創建矩形標籤

這就是我一直在玩無濟於事:

<Image Margin="25,4,14,46" 
      Name="MainImage" 
      Stretch="Uniform" 
      MouseDown="MainImage_MouseDown" 
      Grid.Row="1" 
      HorizontalAlignment="Left" 
      VerticalAlignment="Top" 
      Source="{Binding Path=FileName}" 
      > 
     <Image.Resources> 
      <DataTemplate DataType="{x:Type capp:CAPMeta}"> 
       <Label Content="{Binding Path=TagText}"> 
       </Label> 
      </DataTemplate> 
     </Image.Resources>     
    </Image> 

謝謝!

回答

0

那麼,我最終使用帶有包含綁定文本的ItemResources的畫布來解決此問題。