Select to view content in your preferred language

editor widget and attribute window

1058
6
01-05-2011 12:42 PM
ChrisBradberry
Deactivated User
Hey,

I have the editor widget set up, and I have a feature layer ready for editing.  I am able to add a polygon, but when I finish the poly, the system crashes.  The other tools seem to work, except for the attributes tool.  When I click on the attributes button and click on a feature polygon, the system crashes. 

Does anybody know why the attributes window would crash?  I am using Silverlight 2.1.

Thanks, Chris
0 Kudos
6 Replies
dotMorten_esri
Esri Notable Contributor
I'm terrible at guessing errors, so could you elaborate on "the system crashes" ? Does the entire system go down, just the browser, or just the silverlight app inside the browser, or...? Do you get a stacktrace? (and if so, what does it contain). If you run in debug mode, will it automatically hit a breakpoint in VS where you can get more information about what happened?
0 Kudos
ChrisBradberry
Deactivated User
I have finally found what seems to be the problem.  When I have a tool that uses a draw surface, like a query task, the editing attribute window will not open, and the just in time debugger pops up.   Here is the error:

An unhandled exception('Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidOperationException: Cannot resolve TargetName
DisabledVisualElement

The error does not occur when I have the ShowAttributesOnAdd =  False, but if I try to show the attributes using the attributes button on the editor widget, I get the error.

I do not need to run the query task for the error to happen.  If I comment out the xaml for the button that calls the query task, I will not get the error.

I also had this problem when I was using the area and perimeter tool sample in the utilities folder.

Thanks,
0 Kudos
JenniferNery
Esri Regular Contributor
I could not replicate the issue. Do you mind sharing some code?

Using API v2.1 final assemblies, I tried to combine the following SDK samples as you described:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AreasAndLengths
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitEditorWidget

Set EditorWidget ShowAttributesOnAdd="True"
Add new polygon
I get the attribute window to display without the application crash

Can you send us the StackTrace? Or give us the steps to reproduce given the samples above? Do you have some Action or Behavior that is active?
0 Kudos
ChrisBradberry
Deactivated User
Jennifer,

I started over with a clean template and am trying to reproduce the problems, and I can't.  I am going to put all the tools in one at a time and try to figure out where the problem starts.  If I figure it out, I will post it to this.

Thanks, Chris
0 Kudos
ChrisBradberry
Deactivated User
Jennifer,

I uncovered the problem.  I was using code to create a toggle button, making a button into a tool, and that was causing the conflict with the editing attribute window.  I changed the behavior from the button keeping the draw surface enabled to the having the draw surface enabled while the dockable window is open.  The code that caused the conflict is:

   #region toggle group

        public static string GetToggleGroup(DependencyObject obj)
        {
            return (string)obj.GetValue(ToggleGroupProperty);
        }

        public static void SetToggleGroup(DependencyObject obj, string value)
        {
            obj.SetValue(ToggleGroupProperty, value);
        }

        // Using a DependencyProperty as the backing store for ToggleGroup.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ToggleGroupProperty =
            DependencyProperty.RegisterAttached("ToggleGroup", typeof(string), typeof(Utilities), new PropertyMetadata(null, OnToggleGroupPropertyChanged));


        private static void OnToggleGroupPropertyChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
        {
            if (!(dp is ToggleButton))
                throw new ArgumentException("Toggle Group can only be set on ToggleButton");
            ToggleButton button = dp as ToggleButton;
            string newID = (string)args.NewValue;
            string oldID = (string)args.OldValue;
            if (oldID != null && groups.ContainsKey(oldID))
            {
                groups[newID].Remove(button);
                button.Checked -= button_Checked;
            }
            if (newID != null)
            {
                if (!groups.ContainsKey(newID))
                {
                    groups.Add(newID, new List<ToggleButton>());
                }
                groups[newID].Add(button);
                button.Checked += button_Checked;
            }
        }

        private static void button_Checked(object sender, RoutedEventArgs e)
        {
            ToggleButton button = sender as ToggleButton;
            string ID = GetToggleGroup(button);
            if (ID != null && groups.ContainsKey(ID))
            {
                foreach (ToggleButton b in groups[ID])
                {
                    if (b != button)
                        b.IsChecked = false;
                }
            }
        }

        private static Dictionary<string, List<ToggleButton>> groups = new Dictionary<string, List<ToggleButton>>(); 
        #endregion


Thanks,
Chris
0 Kudos
JenniferNery
Esri Regular Contributor
Thank you for the follow up. I'm glad you resolved the issue.
0 Kudos