Select to view content in your preferred language

A value of type 'ConstrainExtentBehavior' cannot be added to a collection or dictiona

3191
9
07-18-2011 06:39 PM
lancechua
Emerging Contributor
i am currently doing a silverlight c# application , on my xaml pages, i try to add the function


   <
i:Interaction.Behaviors>               
  <esriBehaviors:ConstrainExtentBehavior ConstrainedExtent="-120,30,-60,60" />            </i:Interaction.Behaviors>


but however it gave me this two errors

The tag 'ConstrainExtentBehavior' does not exist in XML namespace 'clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors'.
and
A value of type 'ConstrainExtentBehavior' cannot be added to a collection or dictionary of type 'BehaviorCollection'.

could anyone help me to solve this? thanks!

below is my xaml page if needed.


xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"   
 xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" 
xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"
   xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400"               > 

<Grid x:Name="LayoutRoot" Background="White">     

<esri:Map x:Name="MyMap" Background="White"    >    
         
 <esri:Map.Layers>        

<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"    
                   Url="http://www.onemap.sg/arcgis/rest/services/Basemap/MapServer"/>                 <esri:GraphicsLayer ID="MyGraphicsLayer" />                 
    </esri:Map.Layers>    
 
   <i:Interaction.Behaviors>                
<esriBehaviors:ConstrainExtentBehavior ConstrainedExtent="-120,30,-60,60" />            
 </i:Interaction.Behaviors>       
  
</esri:Map>     
</Grid> 
</UserControl>
0 Kudos
9 Replies
JenniferNery
Esri Regular Contributor
You can look at this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ConstrainExtentBehavior

This should be sufficient if you are using v2.0 or latest:
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"   
0 Kudos
lancechua
Emerging Contributor
😞 i tired but it still doest work
0 Kudos
CameronKuykendall
Emerging Contributor
I was receiving the same error and could not get it to work.  I ended up adding the behavior in the code behind.
0 Kudos
lancechua
Emerging Contributor
I was receiving the same error and could not get it to work.  I ended up adding the behavior in the code behind.


you mean you added the code behind and it worked for you??
0 Kudos
lancechua
Emerging Contributor
anyone know how to solve this?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Most generally this error is due to a mix of dll versions.
But sometimes the mix is coming from the local cached dlls.
You can try this:
   - double check the version of your referenced esri dlls
   - clean your solution
   - exit visual studio
   - remove the bin and obj directories under your projects
   -  rebuild your solution

Hope this help.
BijuThavaran
Emerging Contributor

Thanks Dominique .This is the solution which helped fix a similar issue I was having with ShowCoordinatesBehavior.

0 Kudos
RobertBrodsky
Deactivated User
Hi;
Try this

xmlns:ei2="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"
0 Kudos
JenniferNery
Esri Regular Contributor
Please try the following SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ConstrainExtentBehavior. You can also download SDK and see if you get errors.

Note the following XAML namespace declaration:
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"  
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
0 Kudos