Select to view content in your preferred language

Image Binding?

1011
3
10-22-2010 11:10 AM
ducksunlimited
Deactivated User
HI,

I want to bind images for maptips based on featurelayer.output values. How to set the binding in the Image control? Thanks in advance

<esri:FeatureLayer.OutFields>
        <sys:String>ProjectID</sys:String>
</esri:FeatureLayer.OutFields>

<esri:FeatureLayer.MapTip>
    <StackPanel Margin="7">
            <Image x:Name="OverviewImage" Source=???Images/???+ProjectID+???.png???></Image>
    </StackPanel>                   
</esri:FeatureLayer.MapTip>
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Image Source property expects a BitmapImage. If your image URL still need to be formed from a graphic attribute, you can create your own image converter that will do this type of extra handling.

In your MapTip, you can do:
XAML
<Image x:Name="OverviewImage" Source="{Binding [ProjectID], Converter={StaticResource imageConverter}}" />


Provided you have an ImageConverter that performs this conversion from string to BitmapImage
string imageUrl = string.Format("Images/{0}.png�?�, value);
return new BitmapImage(new Uri(imageUrl , UriKind.Relative)); 
0 Kudos
ducksunlimited
Deactivated User
Thanks for your reply!
Can you provide further assisitance to tell me where to construct the imageConverter?

Image Source property expects a BitmapImage. If your image URL still need to be formed from a graphic attribute, you can create your own image converter that will do this type of extra handling.

In your MapTip, you can do:
XAML
<Image x:Name="OverviewImage" Source="{Binding [ProjectID], Converter={StaticResource imageConverter}}" />


Provided you have an ImageConverter that performs this conversion from string to BitmapImage
string imageUrl = string.Format("Images/{0}.png�?�, value);
return new BitmapImage(new Uri(imageUrl , UriKind.Relative)); 
0 Kudos
dotMorten_esri
Esri Notable Contributor
I think you can use a string format in the binding too to accomplish that.
Ex:
Source="{Binding Binding [ProjectID], StringFormat=Images/{{0}}}"
0 Kudos