I Add a ChekBox using ArcGIS Pro SDK For .NET,how to make it default select。The code below dosn't work. Thanks!
internal class CheckBoxSimplify : ArcGIS.Desktop.Framework.Contracts.CheckBox
{
public CheckBoxSimplify()
{
IsChecked = true;//do not work
}
protected override void OnClick()
{
ModuleSAM.Current.IsSimplify = IsChecked.Value;
base.OnClick();
}
}
Solved! Go to Solution.
Understood, in my example i set the attribute
isChecked="true"
in my config.daml definition of the checkBox to true. That initializes my checkBox on the screen to 'Checked' when i start Pro. But you are correct the code-behind doesn't get called until JIT (Just In Time) triggers loading and the execution of the code. So @LSCGIS would have to set isChecked to true in the DAML and also initialize ModuleSAM.Current.IsSimplify to 'true' to keep the checkbox and the property in sync. If this the case then the loadOnClick value is irrelevant.
Hi,
Try to check add-in daml file. Your checkbox loadOnClick value must be set to false:
<checkBox id="RibbonControls_CheckBox1" keytip="XC" caption="CheckBox 1" className="CheckBox1" loadOnClick="false">
<tooltip heading="CheckBox1 Tooltip Heading">
CheckBox1 Tooltip Heading.
<disabledText />
</tooltip>
</checkBox>
And rebuild solution after changes
This worked for me: At startup I see this:
Using this DAML syntax:
<checkBox id="TestTool_Checkbox" caption="Check Here!"
isChecked="true" className="CheckBoxSimplify"
keytip="C1" >
<tooltip heading="Check Here!">
Test for default being checked<disabledText />
</tooltip>
</checkBox>
I have tried with ArcGIS Pro sdk community sample RibbonControls
In sample original loadOnClick value is false. If I change it to true it works as @LSCGIS wrote, because object constructor is not activated until first checkbox click
Understood, in my example i set the attribute
isChecked="true"
in my config.daml definition of the checkBox to true. That initializes my checkBox on the screen to 'Checked' when i start Pro. But you are correct the code-behind doesn't get called until JIT (Just In Time) triggers loading and the execution of the code. So @LSCGIS would have to set isChecked to true in the DAML and also initialize ModuleSAM.Current.IsSimplify to 'true' to keep the checkbox and the property in sync. If this the case then the loadOnClick value is irrelevant.
Thanks to both of you!
Set isChecked="true" in config.daml works for me.
Set loadOnClick="false" and Set IsChecked = true in ModuleSAM.Current.IsSimplify works same.