<?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: enable/disable button on dock pane based on selection in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623284#M12985</link>
    <description>&lt;P&gt;to answer the questions, yes the name is correct and it is the only selectable layer in the map.&lt;/P&gt;&lt;P&gt;I'm not entirely sure why???? but you were right. It works.&lt;/P&gt;&lt;P&gt;I commented everything out and implemented the check for selection in the button click. Then stepped out for an errand. Saw your post and switched back to this solution and it worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jun 2025 22:46:45 GMT</pubDate>
    <dc:creator>MichaelKohler</dc:creator>
    <dc:date>2025-06-12T22:46:45Z</dc:date>
    <item>
      <title>enable/disable button on dock pane based on selection</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623241#M12983</link>
      <description>&lt;P&gt;trying to enable/disable button on a dock pane based on feature layer selection. if there is a selection on the feature layer, i want to merge the features and put in a different feature layer.&lt;/P&gt;&lt;P&gt;I've tried binding and searched for some examples through, i have to be honest, Chat GPT. This binding thing is new for me. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; The code compiles and builds but the enabled/disabled state doesn't change and there are no errors and nothing happens.&lt;/P&gt;&lt;P&gt;Currently, I've added a test to see if there are selected features to the button click and that works fine. But I would like to one, learn how to get this to work, and two, make the UI better for the user.&lt;/P&gt;&lt;P&gt;.xaml&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Button x:Name="BtnCreateBndy" Content="Run Tool" Command="{Binding RunCommand}" IsEnabled="{Binding IsButtonEnabled}"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code in my view model&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; protected PAMDPViewModel() 
 {
     // Subscribe to selection changes
     MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
 }

 private bool _isButtonEnabled;
 public bool IsButtonEnabled
 {
     get =&amp;gt; _isButtonEnabled;
     set =&amp;gt; SetProperty(ref _isButtonEnabled, value);  // Notifies UI
 }

 public ICommand RunCommand =&amp;gt; new RelayCommand(() =&amp;gt;
 {
     ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Button clicked.");
     // Your button click logic
 }, () =&amp;gt; IsButtonEnabled);


 private void OnSelectionChanged(MapSelectionChangedEventArgs args)
 {
     QueuedTask.Run(() =&amp;gt;
     {
         bool enable = false;

         var selection = MapView.Active?.Map?.GetSelection();
         if (selection != null)
         {
             foreach (var kvp in selection.ToDictionary())
             {
                 var layer = kvp.Key as FeatureLayer;
                 var oids = kvp.Value;

                 if (layer != null &amp;amp;&amp;amp; oids.Count &amp;gt; 0 &amp;amp;&amp;amp; layer.Name == "Parcel Owner")
                 {
                     enable = true;
                     break;
                 }
             }
         }

         // Now safely update UI-bound property on UI thread
         Application.Current.Dispatcher.BeginInvoke(new Action(() =&amp;gt;
         {
             IsButtonEnabled = enable;

             ((RelayCommand)RunCommand).RaiseCanExecuteChanged();

         }));
     });
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 20:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623241#M12983</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2025-06-12T20:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: enable/disable button on dock pane based on selection</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623256#M12984</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your code works fine. Check layer name in TOC. Another one thing is your layer selectable?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 21:23:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623256#M12984</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2025-06-12T21:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: enable/disable button on dock pane based on selection</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623284#M12985</link>
      <description>&lt;P&gt;to answer the questions, yes the name is correct and it is the only selectable layer in the map.&lt;/P&gt;&lt;P&gt;I'm not entirely sure why???? but you were right. It works.&lt;/P&gt;&lt;P&gt;I commented everything out and implemented the check for selection in the button click. Then stepped out for an errand. Saw your post and switched back to this solution and it worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 22:46:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/enable-disable-button-on-dock-pane-based-on/m-p/1623284#M12985</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2025-06-12T22:46:45Z</dc:date>
    </item>
  </channel>
</rss>

