Select to view content in your preferred language

Is it possible to use a DataTemplate for Symbol?

1272
2
10-08-2010 01:47 PM
AlexAgranov
Emerging Contributor
I have ControlTemplate working, but I want to be able to bind to a DataTemplate so that I can get model-data instead of just static UI. So that when I hover the mouse over a graphic(say a Vehicle), that I can retrieve Vehicle info to display through the template(i.e., pop up). I can't do this with ControlTemplate as it has no DataContext.
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
The DataTemplate doesn't have a DataContext either. It's the element that the template gets applied to that has a DataContext. So in other words: Yes you can do this with ControlTemplate too.

You can bind to attributes and symbol properties like so (assuming a FontSize property on the symbol class and a "Title" attribute in the graphic):

<ControlTemplate>
    <TextBlock FontSize="{Binding Symbol.FontSize}" Text="{Binding Attributes[Title]}" />
</ControlTemplate>
0 Kudos
AlexAgranov
Emerging Contributor
The DataTemplate doesn't have a DataContext either. It's the element that the template gets applied to that has a DataContext. So in other words: Yes you can do this with ControlTemplate too.

You can bind to attributes and symbol properties like so (assuming a FontSize property on the symbol class and a "Title" attribute in the graphic):

<ControlTemplate>
    <TextBlock FontSize="{Binding Symbol.FontSize}" Text="{Binding Attributes[Title]}" />
</ControlTemplate>


Thanks, I just wasn't clear on templates to begin with. But how would I assign the DataContext to a Graphic? It's not a FrameworkElement.

Ok - I finally got it. The DataContext is Graphic.
0 Kudos