Select to view content in your preferred language

Maptool updates Dockpane UI. How to access to data binding property from other class?

870
5
Jump to solution
03-22-2024 07:59 AM
nita14
by
Frequent Contributor

Dear Community,

I am struggling to find a way to update an UI element from other class than <*>ViewModel.cs.

I have a docpane with a WaitingCursorControl. Its visibility is cotrolled via data binding in the ViewModel class. However, I do have another MapTool class where I would like to set the visibility of the WaitingCursorControl in the dockpane.

How can access the data binding property from a different class than ViewModel? Any hints?

Thanks!

Adam 

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

1. Find your dockpane:

            DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
            if (pane == null)
                return;

2. Cast pane to you ViewModel class and access public property:

(pane as YourDockpaneViewModel).YourPropertyName = value;

View solution in original post

5 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

1. Find your dockpane:

            DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
            if (pane == null)
                return;

2. Cast pane to you ViewModel class and access public property:

(pane as YourDockpaneViewModel).YourPropertyName = value;
nita14
by
Frequent Contributor

Hi,

Thank you for the snippet. I was somehow close to your solution, did not do casting!

have a nice day,

Adam

0 Kudos
Jeff-Reinhart
Frequent Contributor

@GKmieliauskas Is there a pattern for setting up two-way binding between dockpane elements and an INotifyPropertyChanged enabled class in the dockpane’s view model? I am not seeing anything in the ProGuide and have had no success trying to implement it myself.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

@Jeff-Reinhart Look at the DatastoresDefinitionsAndDatasets sample. DataPath property has two-way binding. DockPane implements INotifyPropertyChanged. OnPropertyChanged is implemented  inside 

SetProperty(ref _dataPath, value, () => DataPath);

You can change it to expanded form:

               _dataPath = value;
                OnPropertyChanged();
 

 

Jeff-Reinhart
Frequent Contributor

That example is immensely helpful. Thanks for helping out a C# rookie.

0 Kudos