Select to view content in your preferred language

Tap into the Map Extent Changed event from a custom control

813
2
07-20-2011 05:57 AM
JasonCleaver
Frequent Contributor
Hello,

I need to create a custom UserControl that can respond to the Map_ExtentChanged event. 

In my class I have the following code:

public static readonly DependencyProperty MapProperty = DependencyProperty.RegisterAttached(
            "Map",
            typeof(ESRI.ArcGIS.Client.Map),
            typeof(NavigationWidget),
            new PropertyMetadata(OnMapPropertyChanged));

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

private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((NavigationWidget)d).Map.ExtentChanged +=new EventHandler<ExtentEventArgs>(Map_ExtentChanged);
           
        }
private static void Map_ExtentChanged(object sender, ExtentEventArgs e) {}

Did I implement this right?

Thanks,

Jason
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Did I implement this right?

At first glance it looks correct.
Do you get some problems with this implementation?
0 Kudos
JasonCleaver
Frequent Contributor
Thanks.

The problem I had was accessing the class objects within the private static void Map_ExtentChanged(object sender, ExtentEventArgs e) {} method.  I eventually figured this out.

Thanks,

Jason
0 Kudos