Set ConstrainExtent in code

406
2
04-05-2010 12:42 PM
ScottMcEachern
New Contributor III
Is it possible to set the ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior in code rather than XAML?  For this use case, the option to use the constrain extent and the envelope are not know until runtime.

Thanks,
Scott
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
A behavior can be added to the behaviors collection coming from  System.Windows.Interactivity.Interaction.GetBehaviors.

Example:

System.Windows.Interactivity.Behavior behavior = new ESRI.ArcGIS.Client.Behaviors.ConstrainExtentBehavior()
{
  ConstrainedExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(-120, 30, -60, 60)
};
System.Windows.Interactivity.Interaction.GetBehaviors(MyMap).Add(behavior);
0 Kudos
ScottMcEachern
New Contributor III
Thanks, that worked!
0 Kudos