Binding a caption text in a mappolygon

2 posts, 0 answers
  1. Parker
    Parker avatar
    7 posts
    Member since:
    Dec 2013

    Posted 03 Dec 2013 Link to this post

    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?

  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 04 Dec 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top