1 Reply Latest reply on Apr 3, 2012 11:57 AM by rzwaap-esristaff

    Create Previous and Next Extents with tools and behavoir

      I'm trying to create two tools, a previous extent and next extent tool.  I've set up a behavior that updates a List of envelopes using the OnExtentChanged event.  Is there a way to access the fields or methods from the Behavior class from within the tool so that I could retrieve one of the envelopes stored in the Behavior?  More simply put, is it possible to refer to my behavior class from a tool?


        • Re: Create Previous and Next Extents with tools and behavoir
          Hi Craig:

          Yes, you can absolutely share the extents, but there is no need to get a reference to the actual behavior instance.  One approach is to add the list of extents to the Application.Current.Resources dictionary, then reference it from your tools.  Another is to create a static property on your behavior class (or even on a new class), then reference that property from your tools.  Or one nice way of doing it would be to create an Attached Property that attaches to the MapApplication type, then store/retrieve the extents from there.  So the code would look something like:

          public static readonly DependencyProperty ExtentsProperty = DependencyProperty.RegisterAttached(
              "Extents", typeof(List<Envelope>), typeof(StoreExtentsBehavior), null);
          public static void SetExtents(MapApplication app, List<Envelope> extents)
              app.SetValue(ExtentsProperty, extents);
          public static List<Envelope> GetExtents(MapApplication app)
              return app.GetValue(ExtentsProperty) as List<Envelope>;

          Then to store extents:

          StoreExtentsBehavior.SetExtents(MapApplication.Current, extentsList);

          And to retrieve extents:


          Hope this helps.