Ribbon checkbox "IsChecked" property

Ribbon for WPF Forum

Posted 17 years ago by Brad Daszynski
Version: 1.0.0345
Avatar
Is there a way to manually set whether a checkbox is checked or not in the ribbon? The "IsChecked" property of the Actipro ribbon checkbox control is read-only. Thanks.

Comments (7)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Brad,

Actually IsChecked does have a public setter on it. I just verified now that setting a ButtonBase's (which CheckBox inherits from) IsChecked property to true checks it.


Actipro Software Support

Posted 17 years ago by Brad Daszynski
Avatar
My mistake. I was trying to set IsChecked.Value, which is read-only. My other question is if I just define a checkbox liks so:

<ribbon:CheckBox Label="myCheckBox" IsChecked="false" Click="OnCheckBoxClick" />

I can't check or uncheck the checkbox in my application! It seems I either have to assign a command to it or define a event handler (see below). Am I missing something?

private void OnCheckBoxClick( object sender, RoutedEventArgs e )
{
RibbonControls.CheckBox b = sender as RibbonControls.CheckBox;
b.IsChecked = !b.IsChecked.Value;
}
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I pasted your code exactly as-is into the RibbonDemo and it worked ok. The checkbox toggled when it was clicked. Your code is correct.


Actipro Software Support

Posted 17 years ago by Brad Daszynski
Avatar
With or without the code-behind I included? Adding just a checkbox with no command or event will NOT allow me to check/uncheck it in the application. I even tried it in the demo app. Try replacing this code:


<ribbon:Tab Label="Check/Radio" KeyTipAccessText="C">
<ribbon:Group Label="CheckBox">
<ribbon:StackPanel SmallVariantGroupSize="Large">
<ribbon:Separator Label="Standard CheckBox" />
<ribbon:CheckBox Label="Toggle Bold" Command="EditingCommands.ToggleBold" />
...
...

with this:


<ribbon:Tab Label="Check/Radio" KeyTipAccessText="C">
<ribbon:Group Label="CheckBox">
<ribbon:StackPanel SmallVariantGroupSize="Large">
<ribbon:Separator Label="Standard CheckBox" />
<ribbon:CheckBox Label="Toggle Bold" />
...
...

All I did was delete: Command="EditingCommands.ToggleBold". Now I can't check or uncheck it...

Am I crazy?
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ahh I apologize, I misread your last post. Yes with the event handler it was updating but without it does not.

We can update this for the next release. How would you like it to work? Should we add something like an IsCheckedToggleEnabled property that will toggle the checked state automatically if it is set to true? If you have other ideas, please be as specific as possible. Thanks!


Actipro Software Support

Posted 17 years ago by Brad Daszynski
Avatar
I think I would change its default behavior to how a default WPF checkbox works. A checkbox can be checked/unchecked unless otherwise specified in code. Not the other way around. This seems like the simplest approach. Assigning a command or having to write code that will check/uncheck a checkbox manually when a user clicks on it doesn't seem like it should be a required step in order to have a checkbox. Although there's no real reason to have a checkbox without any code behind interacting with it (besides demo purposes), what about a situation where there are N number of checkboxes and a user can check which ones he/she wants, then press some sort of submit button? It shouldn't be necessary to add "onClick" or "onCheck" events to your checkboxes just so someone can check/uncheck them. If this type of event is needed by the user, he/she can add it, but should not be required to do it by default. Perhaps all they want to do in this case is check if the "IsChecked" property is true or not.

Hope this helps! Thanks!
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Good points... I'll add an item to the TODO list to add an option for CheckBox as to whether it will auto-check. This way people who do want the more advanced command handlers can process those too.

However here's another question. What about radio buttons and regular checkable buttons? Should this auto-check property be on ButtonBase but default to false for all controls except the checkbox?


Actipro Software Support

The latest build of this product (v24.1.3) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.