Select to view content in your preferred language

UserControl Test

821
2
12-22-2011 06:50 AM
gabrielvazquez
Deactivated User
I am attempting to better understand how to deploy ESRI functionality or tools within usercontrols outside of the mainpage Xaml. I've tested this by replicating the below address locator within its own user control and associated the locator with the main page map using dependencyproperty.

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddressToLocation

I've been able to get the address locator to communicate with the map on the mainpage and the locator works and populates table results. However, their is one problem. I cannot get the graphic layer to appear on the map. I've added the below code to the address locator code, which I found on another similar posting.


public Map Map
  {
   get { return GetValue(MapProperty) as Map; }
   set { SetValue(MapProperty, value); }
  }

  public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map",
     typeof(Map), typeof(AddressLocator), new PropertyMetadata(OnMapPropertyChanged));

  private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  {
   AddressLocator control = d as AddressLocator;
   Map newMap = e.NewValue as Map;
   if(control!=null)
   {
       control._candidateGraphicLayer = newMap.Layers["CandidateGraphicLayer"] as GraphicsLayer;
   }

I have the address locator point results mapped to a Markersymbol, called "ResultsSymbol", which is also defined in the mainpage xaml. and the the "CandidateGraphicLayer" is defined on on the mainpage xaml.
Not sure what I may be doing wrong, but im sure its something simple. If anyone can let me know what I may be doing wrong, thanks.
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor

I have the address locator point results mapped to a Markersymbol, called "ResultsSymbol", which is also defined in the mainpage xaml.

The error might be that your symbol is unknown from your control.
Check that the symbol is not null.

A workaround may be to define a simple renderer for the graphics layer. So the graphics no longer need symbols.
0 Kudos
gabrielvazquez
Deactivated User
Thank you, that workaround using a renderer worked.
0 Kudos