Select to view content in your preferred language

How can I pass a string value to a Pane from another Pane

726
4
03-03-2024 07:55 PM
EmersonBarrera
Emerging Contributor

Using ArcGIS Pro 3.2.2, I'm a novice in C# and new to the ArcGIS Pro SDK.

I have a Dockpane that Zooms and selects a Feature layer 

    featLayer.SetExpanded(true);
    featLayer.SetVisibility(true);
    MapView.Active.ZoomToSelected();

It then Activates a second Dockpane, and its primary function is to update an attribute in the selected FL.

    var UpdateFeatures =  ArcGIS.Desktop.Framework.FrameworkApplication.DockPaneManager.Find("ArcGIS_Update");

    UpdateFeatures.Activate();

The second Dockpane needs to accept a string value the will automatically select a record in a listbox so that user will only need to click an Update button. What is the simplest way to achieve this?

At the moment my work around is, to query the selected Feature Layer to get a value that I then search in the list box and then reposition my list box selection to the record. The user then needs to click the Update button to apply. 

Note, the List Box contains the previous value (currently set on the FL) and updated value (value set from another App) that need to be applied to the selected Feature Layer.

I've tried calling a public method to the .cs of the second Dockpane; this does set a public var to the value from the first Dockpane, but once the Activate is executed, it somehow runs another instance of the Pane and clobbers the value set in the public method call.

I also tried putting a new property in the ViewModel of the DockPane 

    public string PermitValue { get; set; }

but I cannot access this property from the first Dockpane

Thank you in advance for any help.

0 Kudos
4 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Have you tried like this below:

var UpdateFeatures =  ArcGIS.Desktop.Framework.FrameworkApplication.DockPaneManager.Find("ArcGIS_Update");
UpdateFeatures.Activate();
(UpdateFeatures as <second_dockpane_viewmodel>).PermitValue = <some_value>; 
EmersonBarrera
Emerging Contributor

Thank you GKmieliauskas. I tried what you've suggested. The thing is, I'm getting a null value when I check the PermitValue in the XAML.cs when the DockPane is loaded. I think this is plain C# ignorance on my side but don't know where am I getting it wrong. 

0 Kudos
GKmieliauskas
Esri Regular Contributor

Why do you use code behind (xaml.cs) with dockpane? Can you share parts of code?

0 Kudos
EmersonBarrera
Emerging Contributor

Thanks for your patience GKmieliauskas. The process starts from the first Dockpane, which is on the else if (action == "updatepermit") of 
ArcSwitchboard.xaml.cs.txt where I call the (OtherPermitUpdateFeatures as OtherPermitUpdateViewModel).permitValue = value; from here, I set the public var permitValue on the ViewModel () in the OtherPermitUpdateViewModel.cs.txt. And in the OtherPermitUpdate.xaml.cs.txt I'm trying to access the public variable  in the private void GetRecordfromDatasource()

    var vm = new OtherPermitUpdateViewModel();
    var xyz = vm.GetPermitValue;
    MessageBox.Show(xyz.ToString());

It is a bit of a mess at the moment as I've been trying all sorts of things. But the intention is to use the PermitValue or permitNum to reposition/select my Listbox record so I can apply the New Permit number to the Feature Layer currently selected once the user click on the Updat button.

 

0 Kudos