Select to view content in your preferred language

Buttons bound to Editor.Add command never enable

1028
5
Jump to solution
06-21-2012 10:39 AM
markcheyne
Deactivated User
A real hair puller.

I've got some Editor UI, with System.Windows.Controls.Buttons for various Select, Modify, Add commands. They are data bound in the XAML, like

<Button x:Name="ButtonAddPolyline" Margin="2" Width="24" Height="24" ToolTipService.ToolTip="Add Polyline" Command="{Binding Add}" Tag="Polyline" Click="AddButton_Click">


I also have UI to select the edit layer and feature template. When I select a feature template for the polyline layer in my map, my code sets the Editor LayerIDs to that single layer, and sets the Add Command's parameter to be the TypeID of the selected feature template. Then this button should enable.

It WORKS when I test my UI on an ESRI map service such as http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer

IT does NOT work when I use my own feature service such as http://uadnrmaps.wi.gov/ArcGIS/rest/services/DG/DG_ELT_TestData_WTM_ext-edit/FeatureServer. Other commands such as various Select and Modify (EditVertices, Split, Reshape) DO enable as expected.

Is there anything special one must do with a feature class/dataset, MXD or feature service for Add to be enabled?

What I've got:
    my feature classes are not registered as versioned
    my feature classes have subtypes (the basis of the feature templates and TypeIDs used in the SL API), and the subtype column is also used for symbolization in the MXD using a unique value renderer.
    my map service properties appear to be comparable with the ESRI one cited above.

Thank you!
0 Kudos
1 Solution

Accepted Solutions
markcheyne
Deactivated User
finally solved my problem. It was a question of the datatype of the variable being assigned to the button's CommandParameter. You MUST set the button's CommandParameter to one of the layer's subtype values. AND the datatype has to match. That is, if the subtype column is integer with values 0,1, or 2, you can't set the CommandParameter to "0", "1" or "2", which is what will happen if for example you just do a 'CommandParameter="1"' in the Button's XAML. If you want to do it in XAML, you have to spell it out thusly:

<Button Command="{Binding Add}" Margin="2"   ToolTipService.ToolTip="Fire"   Content="Add Polygon">  <Button.CommandParameter>   <sys:Int32>2</sys:Int32>  </Button.CommandParameter> </Button> 


If you do it in code, make sure the value being assigned is the right type.

Once again, DUH.  😉

View solution in original post

0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
I tested with your services and I didn't reproduce the issue.

Have you set correctly the LayerIDs of the Editor Widget?
0 Kudos
markcheyne
Deactivated User
Dbroux - thanks very much for your reply.

Could you maybe send me a working example (zipped solution), or post snippets here? I am definitely missing something.

After your reply and my initial "no way!" reaction, I tried to duplicate your result - make a simplest-case editor from scratch - With my service, I have the same problem as always - I can use the EditVertices command successfully for example, but Add never enables. With the the same code, simply swapping in the ESRI service, Add enables fine.

I am certainly setting the LayerIDs property to an array of one layerID at a time. I am also setting the Add CommandParameter to the typeid of one of the layer's subtypes.

Can you explain why I wouldn't have problems with the ESRI service, but I do with mine? What effect could two different services have?

Thanks again.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Your services seems down for now, so I can't provide you a working example with them.

But my previous test was simply based on the EditorWidget sample after replacing the ESRI services by yours.
0 Kudos
markcheyne
Deactivated User
😧 I appreciate your attention.

A better SDK sample to represent my problem is the 'Edit Tools - Explicit Save' sample, because it binds various Buttons to Editor Commands rather than using the EditorWidget that buries that all inside the widget.

Using that sample with my services illustrates my problem - you'll see the 'Add Polygon' button is enabled when using its original ESRI services, it is disabled when using our services.

For example, change the URLs for the GeometryService, BaseLayer, and FeatureLayer on lines 12, 18, 20 of EditToolsExplicitSave.xaml to:

Also remove the Extent on line 16, it is inappropriate for our SR.

And change the Add CommandParameter for the button on line 46 to 0, 1, or 2.

It's the 'it works with Service A but not with Service B that is throwing me. Like there is some service property I'm missing?
0 Kudos
markcheyne
Deactivated User
finally solved my problem. It was a question of the datatype of the variable being assigned to the button's CommandParameter. You MUST set the button's CommandParameter to one of the layer's subtype values. AND the datatype has to match. That is, if the subtype column is integer with values 0,1, or 2, you can't set the CommandParameter to "0", "1" or "2", which is what will happen if for example you just do a 'CommandParameter="1"' in the Button's XAML. If you want to do it in XAML, you have to spell it out thusly:

<Button Command="{Binding Add}" Margin="2"   ToolTipService.ToolTip="Fire"   Content="Add Polygon">  <Button.CommandParameter>   <sys:Int32>2</sys:Int32>  </Button.CommandParameter> </Button> 


If you do it in code, make sure the value being assigned is the right type.

Once again, DUH.  😉
0 Kudos