Select to view content in your preferred language

ClosedFacility -

631
3
10-21-2010 10:56 AM
ShaningYu
Honored Contributor
Scenario description
1) Create a UserControls file by loading the ClosedFacility component from ESRI: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClosestFacility
2) Add some code in MainPage.xaml and MainPage.xaml.cs to load the ClosedFacility dialog when it is needed.  Also set this component's _Map the same as the parent's (MainPage defined):
            MyClosedFacility.SetParent(this);
            MyClosedFacility.SetMap(MyMap);
However, when the dialog pops out, all of the buttons (except for the Clear button) are greyed out.  Thus, no featurs (points, lines or polygons) can be added.
I don't know why those buttons are greyed-out.  I appreciate if you can provide your hint.  Thanks.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
I think this is related to another post http://forums.arcgis.com/threads/15443-User-controls-code-structuring

When using different UserControls, you can create a DependencyProperty (Map) on the UserControl or set DataContext and update your binding statements.
0 Kudos
ShaningYu
Honored Contributor
Jennifer:
I checked the reference link you provided and but not successful.  In debugging, I tried to track the values of the buttons (e.g. one of them is the FacilityRadioButton).   The FacilityRadioButton.IsEnbled is always 'false' even though I tried
  this.FacilitiesRadioButton.IsEnabled = true;
in the constructor.
I tried find where how the buttons are set initially but no clue has been obtained from the existing code.  I can't understand that why the ClearButton.IsEnabled = true always.
Wish you can provide some clues if you can.  Thanks.
Shaning
0 Kudos
JenniferNery
Esri Regular Contributor
All the buttons have Command binding which can only be resolved if their DataContext is resolved. In this sample, each button's DataContext is set to an Editor which is part of Resources.  Each of these editors has their Map property bound to a map, using Element binding.

Since you are moving this to a different UserControl that does not contain your map, Element binding will not work. You need to resort to other means of binding. Maybe create your own DependencyProperty (Map) in the UserControl so that you can use this instead.
0 Kudos