Search code examples
wpf.net-3.5data-bindingphoto-tagging

WPF Create Rectangle Tags on Image from DataBinding


I'm trying to add image tags to a WPF image and I'm not having much luck. I'd like to do it through databinding if at all possible. Can I set a resource with a DataTemplate to take care of this?

Here's what I've been playing with to no avail:

    <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>

Thanks!


Solution

  • Well, I ended up using a canvas with ItemResources containing bound text to resolve this issue.