+ Reply to Thread
Results 1 to 2 of 2

Thread: Create Previous and Next Extents with tools and behavoir

  1. #1
    Craig Patterson
    Join Date
    Jan 2011
    Posts
    22
    Points
    1
    Answers Provided
    1


    0

    Default 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?

    Thanks,

    Craig

  2. #2
    Rich Zwaap
    Join Date
    Mar 2010
    Posts
    77
    Points
    44
    Answers Provided
    5


    0

    Default 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:

    Code:
    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:

    Code:
    StoreExtentsBehavior.SetExtents(MapApplication.Current, extentsList);
    And to retrieve extents:

    Code:
    StoreExtentsBehavior.GetExtents(MapApplication.Current);
    Hope this helps.
    Rich Zwaap
    Software Developer
    ArcGIS Runtime SDK for .NET, ArcGIS Viewer for Silverlight

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts