Select to view content in your preferred language

Set FeatureDataform to LayerID of the Editor

1009
6
Jump to solution
01-12-2012 07:11 AM
JayKappy
Frequent Contributor
Can I set the Feature Layer Path of a FeatureDataForm to the Editor LayersID?
Below I have the Editor LayerIDs hardcoded for example....In my code its removed and I am changing this in VB based on a radio button selection

Can I set the FeatureDataForm up to point to what ever the Editor LayerIDs feature is?

<esri:Editor x:Key="MyEditor"                 Map="{Binding ElementName=MyMap}"                  LayerIDs="MG_Polygon"                   GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"


<Border x:Name="DataFormBorder" Visibility="Collapsed"            HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,10,10,0" Width="300" Height="300" >           <Border.Effect>                 <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />           </Border.Effect>      <StackPanel Orientation="Vertical">            <esri:FeatureDataForm x:Name="FeatureDataForm" EditEnded="CloseMePoint"                     FeatureLayer="{Binding Path=Layers[MG_Point], ElementName=MyMap}"                                          IsReadOnly="False" LabelPosition="Left" />            <Button x:Name="CloseButton1" Width="75" Height="20"                    Content="Close" Margin="0,10,0,0" Click="CloseButton"/>      </StackPanel> </Border>
0 Kudos
1 Solution

Accepted Solutions
ChristopherHill
Deactivated User
Jay,

You will have to handle the swapping of which FeatureLayer you want in the code behind. When your radio button selection changes the checked event of the radio button could set the FeatureDataForm.FeatureLayer property with the radio button matching layer. Whats the reason you are using radio buttons, what i usually do is place a common MouseLeftButtonUp event on all my FeatureLayers, then when the user clicks on any graphic the editor will be set to that feature layer and the graphic that was just clicked. All you need at that point is a button that the user can click to indicate they want to edit a graphic. They click the button which sets a boolean that means editing is active, when they click a graphic you show the editor and reset the boolean back to false. This way you will not have to add radio buttons for each layer, and you will not have to use more than one FeatureDataForm in you application.

View solution in original post

0 Kudos
6 Replies
JayKappy
Frequent Contributor
Something like this????

Or can I set the FeatureDataForm FeatureLayer at the same time I set the Editor LayerIDs in the vb code below?

<esri:Editor x:Key="MyEditor"
                Map="{Binding ElementName=MyMap}" 
                GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"


            EditLayer2.Text = "MG_Point"
            Dim MyEditor = TryCast(Me.LayoutRoot.Resources("MyEditor"), Editor)
            MyEditor.LayerIDs = New String() {EditLayer2.Text}



<Border x:Name="DataFormBorder" Visibility="Collapsed" 
         HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,10,10,0" Width="300" Height="300" >
      <Border.Effect>
             <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />
       </Border.Effect>
       <StackPanel Orientation="Vertical">
                 <esri:FeatureDataForm x:Name="FeatureDataForm" EditEnded="CloseMePoint"
                        FeatureLayer="{Binding Path=SET THIS TO EDITOR LAYERIDs, ElementName=MyMap}"                      
                        IsReadOnly="False" LabelPosition="Left" />
                 <Button x:Name="CloseButton1" Width="75" Height="20" 
                        Content="Close" Margin="0,10,0,0" Click="CloseButton"/>
       </StackPanel>
</Border>
0 Kudos
JayKappy
Frequent Contributor
I am confusing myself here...

I am creating an edit session that is allowing the user to add points, lines, polygons...
Additionally I have a MouseDown Event on the Layers in the project (same as ones set for edit, add and delete)...When the user selects a feature it opens the Featuredataform for edit...right now I have a dataform for each type, but the list of selectable features is going to grow and dont want to keep having to add additional dataforms.

I am trying merge all the Add New Feature and Select/Modify Feature into one Dataform.  but need to set the FeatureLayer of the dataform for the select....tryign to find otu how to combine all of this.....
If any of that makes sense

I GUESS WHAT I AM LOOKING FOR IS THIS EXAMPLE...BUT have it open the FeatureDataform with the attributes to edit them as well as adding new features....


http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsAutoSave

I think that I can reslve this if I can figure out how to set the FeatureLayer of the FeatureDataForm = to that of the Editor LayerIDs .... SEE LAST POST

Thanks

I am doign this on EDIT COMPLETED, but not the select...I need to:
Change the FeatureLayer on teh dataform
Open the Dataform
All of this on the SELECT

    Private Sub Editor_EditCompleted(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Client.Editor.EditEventArgs)

        Dim Test As String = Me.EditLayer2.Text

        ' e.Edits contains graphics that where added and the layer the graphic was added to
        If e.Action = ESRI.ArcGIS.Client.Editor.EditAction.Add Then
            For Each change As ESRI.ArcGIS.Client.Editor.Change In e.Edits
                FeatureDataForm.FeatureLayer = TryCast(change.Layer, FeatureLayer)
                FeatureDataForm.GraphicSource = change.Graphic
                DataFormBorder.Visibility = Visibility.Visible
           Next
        End If

    End Sub
0 Kudos
ChristopherHill
Deactivated User
Jay,

You will have to handle the swapping of which FeatureLayer you want in the code behind. When your radio button selection changes the checked event of the radio button could set the FeatureDataForm.FeatureLayer property with the radio button matching layer. Whats the reason you are using radio buttons, what i usually do is place a common MouseLeftButtonUp event on all my FeatureLayers, then when the user clicks on any graphic the editor will be set to that feature layer and the graphic that was just clicked. All you need at that point is a button that the user can click to indicate they want to edit a graphic. They click the button which sets a boolean that means editing is active, when they click a graphic you show the editor and reset the boolean back to false. This way you will not have to add radio buttons for each layer, and you will not have to use more than one FeatureDataForm in you application.
0 Kudos
JayKappy
Frequent Contributor
Thats what I am after....how do I set the edit as active, set the dataform to the Editor LayerIDs and then open the form all from the button?
0 Kudos
JayKappy
Frequent Contributor
Thats starting to make sense now....

THis is what I have...for the Select and Modify....now to handle the ADD Feature

What I was doing with teh Radio buttons was defining the LayerIDs in the editor...HOW ELSE can I set which feature I want to be the editing feature...
If I get this then on the EditCompleted I can open the Dataform etc. and add my attributes...

SO I guess I simply need to figure out how to set the LayerIDs of the editor before I hit the Add Button, IF I DONT use the readio buttons to determine which feature I was to add!.

Thanks a ton for your feedback....helpfull in thinking this through....

<esri:Editor x:Key="MyEditor" 
       Map="{Binding ElementName=MyMap}" EditCompleted="Editor_EditCompleted"              
       GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"  />


THIS IS THE RADIO button part settinga textblock to a value and then setting the LayerIDs of the Editor...
How can I do this differently?

    Private Sub HandleCheck(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Dim rb As RadioButton = TryCast(sender, RadioButton)
        EditLayer.Text = "You are now editing: " + ": " + rb.Name

        Dim _checkedValue As String = rb.Name

        If _checkedValue = "Point" Then
            EditLayer2.Text = "MG_Point"
            Dim MyEditor = TryCast(Me.LayoutRoot.Resources("MyEditor"), Editor)
            MyEditor.LayerIDs = New String() {EditLayer2.Text}
        ElseIf _checkedValue = "Line" Then
            EditLayer2.Text = "MG_Line"
            Dim MyEditor = TryCast(Me.LayoutRoot.Resources("MyEditor"), Editor)
            MyEditor.LayerIDs = New String() {EditLayer2.Text}
        ElseIf _checkedValue = "Polygon" Then
            EditLayer2.Text = "MG_Polygon"
            Dim MyEditor = TryCast(Me.LayoutRoot.Resources("MyEditor"), Editor)
            MyEditor.LayerIDs = New String() {EditLayer2.Text}
        Else

        End If
    End Sub


<Border Background="#FF919191" BorderThickness="1" CornerRadius="5" x:Name="editborder"
          HorizontalAlignment="Right"  VerticalAlignment="Top"
           Padding="5" BorderBrush="Black" Margin="0,5,5,15" Visibility="Visible">
                 <StackPanel x:Name="EditorTools" Orientation="Vertical" >
                       <StackPanel Orientation="Horizontal">
                             <Button Command="{Binding Add}" Margin="2" x:Name="AddButton" DataContext="{StaticResource MyEditor}"
                                    ToolTipService.ToolTip="Point"  Width="90"Content="Add">
                                          <Button.CommandParameter>
                                                <sys:Int32>10101</sys:Int32>
                                           </Button.CommandParameter>
                             </Button>
                       </StackPanel>
                 </StackPanel>
</Border>


<esri:FeatureLayer ID="MG_Point" Visible="True"  MouseLeftButtonUp="Feature_MouseLeftButtonUp"         
         Url="http://189/ArcGIS/rest/services/Maple/MG_FS/FeatureServer/22"
         DisableClientCaching="True" Mode="OnDemand" 
         SelectionColor="#FFFFFF00" OutFields="*"  />
<esri:FeatureLayer ID="MG_Line" Visible="True"  MouseLeftButtonUp="Feature_MouseLeftButtonUp"
        Url="http://189/ArcGIS/rest/services/Maple/MG_FS/FeatureServer/23"
        DisableClientCaching="True" Mode="OnDemand"
        SelectionColor="#FFFFFF00" OutFields="*" />


    Private Sub Feature_MouseLeftButtonUp(ByVal sender As System.Object, ByVal args As GraphicMouseButtonEventArgs)

        Dim featureLayer As FeatureLayer = TryCast(sender, FeatureLayer)
        For Each g As Graphic In featureLayer.Graphics
            If (g.Selected) Then
                g.UnSelect()
            End If
        Next

        args.Graphic.Select()
        FeatureDataForm.GraphicSource = args.Graphic
        FeatureDataForm.FeatureLayer = featureLayer
        DataFormBorder.Visibility = Visibility.Visible
    End Sub


    Private Sub Editor_EditCompleted(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Client.Editor.EditEventArgs)
        Dim Test As String = Me.EditLayer2.Text

        ' e.Edits contains graphics that where added and the layer the graphic was added to
        If e.Action = ESRI.ArcGIS.Client.Editor.EditAction.Add Then
            For Each change As ESRI.ArcGIS.Client.Editor.Change In e.Edits
                'FeatureDataForm.GraphicSource = change.Geometry
                FeatureDataForm.FeatureLayer = TryCast(change.Layer, FeatureLayer)
                FeatureDataForm.GraphicSource = change.Graphic
                DataFormBorder.Visibility = Visibility.Visible
           Next
        End If

    End Sub
0 Kudos
JayKappy
Frequent Contributor
I think what I have above solves my issues...

I am able to select any feature and edit it...
I am able to choose with the radion buttons which feature i want to add features to and then add them....

Think I am good to go...unless you have thoughts about how else I can determine which feature to add/delete from other than radio buttons or a combobox etc...

THANKS A TON....
0 Kudos