Select to view content in your preferred language

Magnifying Glass - Map Binding

800
2
10-06-2010 07:50 AM
ShaningYu
Honored Contributor
I loaded ESRI's MagnifyingGlass component.  However, the Magnifying Glass tool
1) Does not bind the street map but display an image map (see the image attached)
2) There is no magnifying function at all
The codes are listed below:
        <esri:MagnifyingGlass x:Name="MyMagnifyingGlass" Visibility="Visible"
                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                         Map="{Binding ElementName=_Map}" >
            <esri:MagnifyingGlass.Layer>
                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                    Url="http://services.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer"/>
            </esri:MagnifyingGlass.Layer>
        </esri:MagnifyingGlass>
where the _Map is defined in its .cs file:
        private MainPage _Parent;
        private Map _Map;
        public void SetMap(Map TheMap)     {
            _Map = TheMap;
        }

        public void SetParent(MainPage TheParent)     {
            _Parent = TheParent;
        }

Please help if you know why.  Thanks.
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
You cannot use Element binding if _Map is not an element of your application. In other words, you can only use this
Map="{Binding ElementName=_Map}"
if you had
<esri:Map x:Name"_Map"/>

Since you define _Map in code-behind, you can also update your MagnifyingGlass' Map property in code behind:
MyMagnifyingGlass.Map = _Map;

Or you can define _Map as a StaticResource and update your binding.
<esri:Map x:Key="_Map"/>
private Map _Map = this.Resources["_Map"] as Map;
Map="{Binding Source={StaticResource _Map}}"
0 Kudos
ShaningYu
Honored Contributor
Jenniffer:
It works per your feedback.  Thanks a lot.
Shaning
0 Kudos