This is a migrated thread and some comments may be shown as answers.

Binding a caption text in a mappolygon

1 Answer 32 Views
Map
This is a migrated thread and some comments may be shown as answers.
Parker
Top achievements
Rank 1
Parker asked on 03 Dec 2013, 05:50 PM
I'm attempting to bind a TextBlock in a CaptionTemplate but it's not working.  If I just replace the binding with text it works fine.

Here is the code that does not display the caption:
<telerik:InformationLayer Name="InformationLayerShape" ItemsSource="{Binding LayerShapes}">
<telerik:InformationLayer.ItemTemplate>
  <DataTemplate>
    <views:MapPolygon Points="{Binding Locations}"
      Fill="#99FFFF00"
      StrokeThickness="4"
      Visibility="{Binding Visibility}" CaptionLocation="{Binding CaptionLocation}"
      Opacity=".5">
        <views:WaterMapPolygon.CaptionTemplate>
          <DataTemplate>
            <TextBlock Text="{Binding CaptionText}" />
          </DataTemplate>
        </views:WaterMapPolygon.CaptionTemplate>
     </views:MapPolygon>
  </DataTemplate>
</telerik:InformationLayer.ItemTemplate>
</telerik:InformationLayer>

If I replace  <TextBlock Text="{Binding CaptionText}" />
with  <TextBlock Text="Display this caption." />
t
he text is displayed.


How do I bind this to a property?

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Dec 2013, 07:34 AM
Hello Parker,

Unfortunately the CaptionTemplate does not support binding except of binding to extended data of the map shape.

To show captions in your case I would recommend to add another information layer with the same ItemsSource using a data template which shows captions.

The sample code is below.
<telerik:InformationLayer Name="InformationLayerCaption" ItemsSource="{Binding LayerShapes}">
    <telerik:InformationLayer.ItemTemplate>
        <DataTemplate>
            <TextBlock telerik:MapLayer.Location="{Binding CaptionLocation}" Visibility="{Binding Visibility}" Text="{Binding CaptionText}" />
        </DataTemplate>
    </telerik:InformationLayer.ItemTemplate>
</telerik:InformationLayer>

Regards,
Andrey Murzov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.

Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.

Sign up for Free application insights >>
Tags
Map
Asked by
Parker
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or