Select to view content in your preferred language

How do I find element created by another Add-In?

2252
3
02-15-2013 08:27 AM
by Anonymous User
Not applicable
Original User: Steve Clark

I have a custom Identify add-in that creates a datagrid. I have another add-in button that clears graphics but I also want it to find and close the datagrid too. I tried MapApplication.Current.FindObjectInLayout but that does not find any of the datagrid names (e.g., "IdentifyDetailsDataGrid"). How would I go about finding this object or at least to get an enumerated list of objects in the current MapApplication?
0 Kudos
3 Replies
ScottFriedrich
Regular Contributor
Steve,

I have used VisualTreeHelper in the past to find elements within the application:

edit: use Silverlight Spy to help find your element.

[ATTACH=CONFIG]21900[/ATTACH]


Good Luck,

Scott
0 Kudos
by Anonymous User
Not applicable
Original User: hochas

FindObjectInLayout only works for elements that is in your layout, so unless your DataGrid is created straight in the layout you wont find it that way. To close the datagrid if its in another window, try adding a static close-event to the add-in containing the DataGrid, then calling that static method when you run your clear graphics add-in.
0 Kudos
YurongTan
Regular Contributor
I added an WindowPanel around the DataGrid panel like this:

        <userControls:WindowPanel x:Name="ResultDisplayWindowCAP"
            IsOpen="{Binding ElementName=btnSearchStringEntry, Path=IsChecked, Mode=TwoWay}"
            HorizontalAlignment="Center" VerticalAlignment="Bottom" MinWidth="280" MaxHeight="300"
            Background="Lavender" >
            ...

And then use other controls its visibility such as:
        private void LayoutRoot_Close_misc_windows_Loaded(object sender, RoutedEventArgs e)
        {
            ResultDisplayWindowCAP.IsOpen = false;
       }

The user can also dismiss this WindowPanel.  I also add some other controls such as to save the DataGrid to an Excel file or do something else.
0 Kudos