<?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: Uncheck checkboxes on a Custom Control from another form. in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325527#M10320</link>
    <description>&lt;P&gt;yes, sorry about that. the cast wont work. i forgot that the wrapper cannot be cast to the view model directly. The view model "itself" is held in an internal property.&lt;/P&gt;&lt;P&gt;Change the code like so:&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;internal class Module1 : Module  {
   //Add another property to your module for the custom control
    public CustomControlViewModel1 CustomControlViewModel1  { get; set;}

internal class CustomControlViewModel1 : CustomControl {
    //add a default ctor
    public CustomControlViewModel1() {
      //set it here in the ctor of your custom control vm
      Module1.Current.CustomControlViewModel1 = this;
    }

//call refresh on the module property - add a null check
//if CustomControlViewModel1 -is- null it means that it has not been
//instantiated yet - presumably because the ribbon tab it is sited on
//has never been activated in the session...in which case it does not
//need to be refreshed.
Module1.Current.CustomControlViewModel1?.Refresh();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2023 17:53:24 GMT</pubDate>
    <dc:creator>CharlesMacleod</dc:creator>
    <dc:date>2023-09-05T17:53:24Z</dc:date>
    <item>
      <title>Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1324108#M10273</link>
      <description>&lt;P&gt;I have a plugin that streams imagery and basmaps from proprietary apis. This has Login/Logout functionality. Logout should reset everything to the state before login (i.e. checkboxes should be unchecked and combo box value set back to default value). In this addin I have a split button on the ribbon with a custom control for the dropdown. This custom control has 4 checkboxes. I need to uncheck any checked boxes at logout. I am having difficulty achieving this. How do I access the checkboxes on a custom control from another form.&lt;/P&gt;&lt;P&gt;I have set up public and private bools in the custom control View Model as shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private bool _isSelectedPremium;
public bool IsSelectedPremium
{
	get { return _isSelectedPremium; }
        set
        {
            _isSelectedPremium = value;
            NotifyPropertyChanged("IsSelectedPremium");
        }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The public bool is bound to the check box in the xaml:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;CheckBox Name="PremiumChkBx" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" IsChecked="{Binding IsSelectedPremium}"/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am able to do the business logic I need when checked on or off.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I cannot get the checkboxes to reset (uncheck if checked) at logout.&amp;nbsp; The Logout is a button click event handled in another form.&lt;/P&gt;&lt;P&gt;Any help is appreciated, thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 21:14:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1324108#M10273</guid>
      <dc:creator>IanBaca2</dc:creator>
      <dc:date>2023-08-30T21:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325451#M10315</link>
      <description>&lt;P&gt;move the backing properties to the Module. The module is accessible from anywhere in the addin. Add a "refresh" method to your custom control view model that fires the property notification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class Module1 : Module {

    private static Module1 _this = null;

    public bool IsSelectedPremium { get; set; }

internal class CustomControlViewModel1 : CustomControl {

    public bool IsSelectedPremium =&amp;gt; Module1.Current.IsSelectedPremium;

    public void Refresh() {
      NotifyPropertyChanged("IsSelectedPremium");
    }


internal class SomeOtherClassElseWhereInTheAddin {

    public void SetCheckboxes(bool loggedIn) {
       Module1.Current.IsSelectedPremium = loggedIn;
       var custom_control_vm = 
          FrameworkApplication.GetPlugInWrapper("Acme_Custom_Control1")
               as CustomControlViewModel1;
       custom_control_vm.Refresh();
    }

        &lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Sep 2023 15:46:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325451#M10315</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-09-05T15:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325494#M10318</link>
      <description>&lt;P&gt;Hello and thanks for the response. I have set up the code as outlined above. However, I am still unable to get this to work. The GetPlugInWrapper("string id") call is returning null so the call to .Refresh() is causing a crash. I see from the documentation that GetPlugInWrapper takes the id of the DAML element. So where you have "Acme_Custom_Control1" I have the id of the custom control from the DAML "X_CustomControl".&lt;/P&gt;&lt;P&gt;Custom Control in config.Daml:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;customControl id="X_CustomControl" keytip="Products" className="CustomControlViewModel" loadOnClick="true" 
                       smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple16.png" 
                      largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple32.png"&amp;gt;
          &amp;lt;content className="CustomControlView" /&amp;gt;
          &amp;lt;tooltip heading="Products"&amp;gt;Choose.&amp;lt;disabledText /&amp;gt;&amp;lt;/tooltip&amp;gt;
        &amp;lt;/customControl&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my code looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void SetCheckboxes(bool loggedIn)
        {
            Module1.Current.IsSelectedPremium = loggedIn;
            var custom_control_vm =
               ArcGIS.Desktop.Framework.FrameworkApplication.GetPlugInWrapper("X_CustomControl")
                    as CustomControlViewModel;
            custom_control_vm.Refresh();
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my&amp;nbsp;custom_control_vm returns null (even after I've opened it and checked a box).&lt;/P&gt;&lt;P&gt;Am I misunderstanding the GetPlugInWrapper string parameter or does this not recognize Custom Controls?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 18:11:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325494#M10318</guid>
      <dc:creator>IanBaca2</dc:creator>
      <dc:date>2023-09-05T18:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325527#M10320</link>
      <description>&lt;P&gt;yes, sorry about that. the cast wont work. i forgot that the wrapper cannot be cast to the view model directly. The view model "itself" is held in an internal property.&lt;/P&gt;&lt;P&gt;Change the code like so:&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;internal class Module1 : Module  {
   //Add another property to your module for the custom control
    public CustomControlViewModel1 CustomControlViewModel1  { get; set;}

internal class CustomControlViewModel1 : CustomControl {
    //add a default ctor
    public CustomControlViewModel1() {
      //set it here in the ctor of your custom control vm
      Module1.Current.CustomControlViewModel1 = this;
    }

//call refresh on the module property - add a null check
//if CustomControlViewModel1 -is- null it means that it has not been
//instantiated yet - presumably because the ribbon tab it is sited on
//has never been activated in the session...in which case it does not
//need to be refreshed.
Module1.Current.CustomControlViewModel1?.Refresh();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 17:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325527#M10320</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-09-05T17:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325615#M10325</link>
      <description>&lt;P&gt;We are getting closer I think.&amp;nbsp; With the above change I can get the checkbox to uncheck at the logout function. However, now it seems the binding for setting the bool to true when clicking to check the checkbox is lost. At first changing my code to what was suggested above, I was given the error "A TwoWay or OneWayToSource binding cannot work on the read-only property 'IsSelectedPremium' of type 'System.String'." So I had to change the Binding Mode to OneWay specifically to run this (I don't know if that is a factor).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your time.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 20:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325615#M10325</guid>
      <dc:creator>IanBaca2</dc:creator>
      <dc:date>2023-09-05T20:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325623#M10326</link>
      <description>&lt;P&gt;If u want to change the property from the UI just change the definition of your property in the view model to be get and set - and make sure the binding is Two-way (which is the default)...so delete out the binding mode stuff (in your xaml) that u added for one-way.&lt;/P&gt;&lt;P&gt;u want something like this in the vm....anyway, keep whittling away at it - sounds like u r almost there &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class CustomControl1ViewModel : CustomControl  {
   //public bool IsSelectedPremium =&amp;gt; Module1.Current.IsSelectedPremium;
    public bool IsSelectedPremium {
      get =&amp;gt; Module1.Current.IsSelectedPremium;
      set
      {
        if (value != Module1.Current.IsSelectedPremium)
        {
          Module1.Current.IsSelectedPremium = value;
          NotifyPropertyChanged();
        }
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 20:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325623#M10326</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-09-05T20:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Uncheck checkboxes on a Custom Control from another form.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325639#M10327</link>
      <description>&lt;P&gt;This worked. I just had to specifically set the bool to false in the Refresh() method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 21:15:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/uncheck-checkboxes-on-a-custom-control-from/m-p/1325639#M10327</guid>
      <dc:creator>IanBaca2</dc:creator>
      <dc:date>2023-09-05T21:15:18Z</dc:date>
    </item>
  </channel>
</rss>

