Select to view content in your preferred language

MeasureAction problem

1326
6
01-07-2011 11:02 AM
ThaoNguyen
Emerging Contributor
I tried to use MeasureAction and got the following error:

A value of type 'MeasureAction' cannot be added to a collection or dictionary of type 'TriggerActionCollection'.

My code:
<i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click" x:Uid="eventTrigger">
                                <esriBehaviors:MeasureAction x:Uid="measureAct"                               
                                    AreaUnit="SquareMiles"
                                    DisplayTotals="True"
                                    DistanceUnit="Miles"
                                    MapUnits="Meters"
                                    MeasureMode="Polygon"                                  
                                    FillSymbol="{StaticResource DefaultFillSymbol}"
                                    TargetName="MainMap"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

Namespaces:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"  
    xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Actions;assembly=ESRI.ArcGIS.Client.Behaviors"

At first I referenced namespace esriBehaviors to ESRI.ArcGIS.Client.Behaviors but found out that MeasureAction class is in Client.Actions namespace.

Please help!  Thanks!
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
Are you using v2.0 or higher? If so, you can reference esri assemblies this way:
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"


Have you looked at the SDK sample for MeasureAction? http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#UtilityActions

I'm not sure why you use x:Uid instead of x:Name but the error message does not seem related to that. Maybe try updating your xaml namespace definition (as above) first.
0 Kudos
ThaoNguyen
Emerging Contributor
Are you using v2.0 or higher? If so, you can reference esri assemblies this way:
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"


Have you looked at the SDK sample for MeasureAction? http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#UtilityActions

I'm not sure why you use x:Uid instead of x:Name but the error message does not seem related to that. Maybe try updating your xaml namespace definition (as above) first.


Yes, I already tried xmlns:esri="http://schemas.esri.com/arcgis/client/2009" first, it didn't resolve the problem. 
I have to use x:uid.  I think it should not affect the esri map.  It is more a common thing in wpf anyway.

I had looked at the sample before I did all of this.  Actually, I'm learning what arcgis offers.
0 Kudos
ThaoNguyen
Emerging Contributor
Yes, I already tried xmlns:esri="http://schemas.esri.com/arcgis/client/2009" first, it didn't resolve the problem. 
I have to use x:uid.  I think it should not affect the esri map.  It is more a common thing in wpf anyway.

I had looked at the sample before I did all of this.  Actually, I'm learning what arcgis offers.


Found out that the attribute TargetName I specified in <MeasureAction> was not correct!
0 Kudos
ThaoNguyen
Emerging Contributor
Found out that the attribute TargetName I specified in <MeasureAction> was not correct!


MeasureAction worked for arcgis 9 but NOT for arcgis 10 :(.
0 Kudos
BrandonCales
Regular Contributor
The tag 'MeasureAction' does not exist in XML namespace http://schemas.esri.com/arcgis/client/2009'.

I'm using Visual Studio 2010..any one get this working?
0 Kudos
IgressT
Emerging Contributor
The tag 'MeasureAction' does not exist in XML namespace http://schemas.esri.com/arcgis/client/2009'.

I'm using Visual Studio 2010..any one get this working?


Try adding ESRI.ArcGIS.Client.Behaviors