Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
925
Specifying a default value when data binding
posted

Hi,

I have a xamMap being bound to a collection of data items for say States. The data only contains data for half the states. What options are there for displaying the caption/tooltip so that if you include the Value or a numeric piece of data that when the data is not present for a particular state it doesn't display NaN i.e.

ToolTip="{}{Name} ({Value})"

This displays as Alaska (NaN)

Thanks,

Chris

Parents
  • 3255
    Verified Answer
    posted

    Hi Chris,

    One way to achieve this is to attach to MapLayer's Imported event and set MapElements' ToolTip explicitly, like in the following code snippet:

    private void MapLayer_Imported(object sender, MapLayerImportEventArgs e)
    {           
     if (e.Action == MapLayerImportAction.End)
     {
      var layer = (MapLayer) sender;
      foreach (var element in layer.Elements)
      {
       if (double.IsNaN(element.Value))
       {
        element.ToolTip = element.Name;
       }
       else
       {
        element.ToolTip = string.Format("{0} ({1})", element.Name, element.Value);
       }
      }
     }
    }

    Regards,

    Ivan Kotev

Reply Children
No Data