<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retrieve user input from ProWindow dialog without global variables? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228788#M9025</link>
    <description>&lt;P&gt;Hello, thanks for your help, but I'm getting an error. once code enters the if statement, _createlotwindow becomes null. I assume this is because I'm setting _createlotwindow.Closed to make the object null on close. It works fine if I set the DataContext before the ShowDialog(). Is there any harm in doing that?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override void OnClick()
        {
            if (_createlotwindow != null)
                return;
            _createlotwindow = new CreateLotWindow();
            _createlotwindow.Owner = FrameworkApplication.Current.MainWindow;
            var viewModel = _createlotwindow.DataContext as CreateLotWindowViewModel;
            _createlotwindow.Closed += (o, e) =&amp;gt; { _createlotwindow = null; };
            if (_createlotwindow.ShowDialog() == true)
            {
                var count = viewModel.LotCount;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaoloSucci_0-1667576546315.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/55316i4BF2210D1725BD54/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaoloSucci_0-1667576546315.png" alt="PaoloSucci_0-1667576546315.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;PaoloSucci_0-1667576546315.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 16:09:07 GMT</pubDate>
    <dc:creator>succip</dc:creator>
    <dc:date>2022-11-04T16:09:07Z</dc:date>
    <item>
      <title>Retrieve user input from ProWindow dialog without global variables?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228558#M9011</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'd like to retrieve user input from a ProWindow dialog, then use that input to do a bunch of stuff in my MapView/Tables. Following this example (&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/ProWindowMVVM" target="_blank" rel="noopener"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Framework/ProWindowMVVM&lt;/A&gt;), I see them using Module1 to store/retrieve global variables, is this best practice in a case where I'll be building multiple ProWindow forms? I worry it will get overwhelming quickly if I want to track 5-10 properties per window.&lt;/P&gt;&lt;P&gt;Is there any other way of retrieving user input from a ProWindow? The ShowDialog() method only returns a boolean.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy to provide more details but I wanted to keep my question as simple as possible. As of right now my code is as follows as an example:&lt;/P&gt;&lt;P&gt;TestButton.cs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;namespace SurreyTools
{
    internal class TestButton : Button
    {
        private CreateLotWindow _createlotwindow;

        protected override void OnClick()
        {
            if (_createlotwindow != null)
                return;
            _createlotwindow = new CreateLotWindow();
            _createlotwindow.Owner = FrameworkApplication.Current.MainWindow;
            _createlotwindow.Closed += (o, e) =&amp;gt; { _createlotwindow = null; };
            _createlotwindow.ShowDialog();
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CreateLotsWindowViewModel:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;namespace SurreyTools
{
    public class CreateLotWindowViewModel: PropertyChangedBase
    {
        private string _lotCount;
        public string LotCount
        {
            get =&amp;gt; _lotCount;
            set
            {
                SetProperty(ref _lotCount, value, () =&amp;gt; LotCount);
            }
        }

        public ICommand SubmitLotNumber =&amp;gt; new RelayCommand((createLotWindow) =&amp;gt;
        {
            (createLotWindow as CreateLotWindow).DialogResult = true;
            (createLotWindow as CreateLotWindow).Close();
        }, () =&amp;gt; true);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like some way to pass the lotCount property to either my button or any other use case.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 22:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228558#M9011</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2022-11-03T22:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve user input from ProWindow dialog without global variables?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228642#M9016</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can use DataContext to access view model properties:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        protected override void OnClick()
        {
            if (_createlotwindow != null)
                return;
            _createlotwindow = new CreateLotWindow();
            _createlotwindow.Owner = FrameworkApplication.Current.MainWindow;
            _createlotwindow.Closed += (o, e) =&amp;gt; { _createlotwindow = null; };
            if(_createlotwindow.ShowDialog()== true) {
                var viewModel = _createlotWindow.DataContext as CreateLotWindowViewModel;
                var count = viewModel.LotCount;
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 04 Nov 2022 06:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228642#M9016</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-11-04T06:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve user input from ProWindow dialog without global variables?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228788#M9025</link>
      <description>&lt;P&gt;Hello, thanks for your help, but I'm getting an error. once code enters the if statement, _createlotwindow becomes null. I assume this is because I'm setting _createlotwindow.Closed to make the object null on close. It works fine if I set the DataContext before the ShowDialog(). Is there any harm in doing that?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override void OnClick()
        {
            if (_createlotwindow != null)
                return;
            _createlotwindow = new CreateLotWindow();
            _createlotwindow.Owner = FrameworkApplication.Current.MainWindow;
            var viewModel = _createlotwindow.DataContext as CreateLotWindowViewModel;
            _createlotwindow.Closed += (o, e) =&amp;gt; { _createlotwindow = null; };
            if (_createlotwindow.ShowDialog() == true)
            {
                var count = viewModel.LotCount;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaoloSucci_0-1667576546315.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/55316i4BF2210D1725BD54/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaoloSucci_0-1667576546315.png" alt="PaoloSucci_0-1667576546315.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;PaoloSucci_0-1667576546315.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 16:09:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228788#M9025</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2022-11-04T16:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve user input from ProWindow dialog without global variables?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228790#M9026</link>
      <description>&lt;P&gt;On Closed event it destroys objects. I don't use that pattern. You can use local variable like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        protected override void OnClick()
        {
            CreateLotWindow createlotwindow = new CreateLotWindow();
            createlotwindow.Owner = FrameworkApplication.Current.MainWindow;
            if(createlotwindow.ShowDialog()== true) {
                var viewModel = createlotWindow.DataContext as CreateLotWindowViewModel;
                var count = viewModel.LotCount;
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 04 Nov 2022 15:50:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228790#M9026</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-11-04T15:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve user input from ProWindow dialog without global variables?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228895#M9027</link>
      <description>&lt;P&gt;Is there a trick to doing this in a RowCreatedEvent? I'm getting a thread issue error trying to call it. I found &lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/prowindow-calling-method-during-an-event/td-p/1099580" target="_self"&gt;this answer&lt;/A&gt; from 2020 but I'm having trouble parsing the code in French. I've tried wrapping everything in the Current.Dispatcher.Invoke() but then my OK button is disabled (I assume because the thread is locked).&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static void OnRowCreated(RowChangedEventArgs args)
        {
            CreateLotWindow createLotWindow = new CreateLotWindow();
            createLotWindow.Owner = FrameworkApplication.Current.MainWindow;
            var vm = createLotWindow.DataContext as CreateLotWindowViewModel;
            if (createLotWindow.ShowDialog() == true)
            {
                string lotNo = vm.LotCount;
                QueuedTask.Run(()=&amp;gt; {
                     // do stuff with user input
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 16:58:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/retrieve-user-input-from-prowindow-dialog-without/m-p/1228895#M9027</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2022-11-07T16:58:59Z</dc:date>
    </item>
  </channel>
</rss>

