My "Draw" tool for drawing a box to zoom in on the map will not work in combination with the ConstrainExtentBehavior. If ConstrainExtentBehavior is set, the tool will "jerk" the map, but never zooms, even though the zoomed geometry is well within the constraint. It will finally zoom after the 2nd or 3rd attempt.
As I workaround, I am setting the ConstrainExtentBehavior in code on UserControl_Loaded, removing it before I zoom, then replacing at the Map_ExtentChanged. Am I missing something here?
System.Windows.Interactivity.Behavior behavior;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
behavior = new ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior()
{
ConstrainedExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(1116757.49248094, 183859.75, 1331330.81621366, 325602.25)
};
System.Windows.Interactivity.Interaction.GetBehaviors(MyMap).Add(behavior);
}
private void myDrawObject_DrawComplete(object sender, DrawEventArgs args)
{
switch (_toolMode)
{
case "zoomin":
System.Windows.Interactivity.Interaction.GetBehaviors(MyMap).Remove(behavior);
MyMap.ZoomTo(args.Geometry as ESRI.ArcGIS.Client.Geometry.Envelope);
break;
}
}
private void MyMap_ExtentChanged(object sender, ExtentEventArgs e)
{
if (System.Windows.Interactivity.Interaction.GetBehaviors(MyMap).Count == 0)
{
System.Windows.Interactivity.Interaction.GetBehaviors(MyMap).Add(behavior);
}
}