Q:

How to programmatically click a CheckBox in WPF?

SO i have CheckBox and since there's no CheckBox.PerformClick() method in WPF, is there a way to click a WPF CheckBox programmatically?
I found this solution but this for Button only:
ButtonAutomationPeer peer = new ButtonAutomationPeer(someButton);
IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProv.Invoke();

A:

You may use the PatternInterface.Toggle interface to toggle the CheckBox:
CheckBoxAutomationPeer peer = new CheckBoxAutomationPeer(someCheckBox);
IToggleProvider toggleProvider = peer.GetPattern(PatternInterface.Toggle) as IToggleProvider;
toggleProvider.Toggle();

Or you can set the IsChecked property:
someCheckBox.IsChecked = !someCheckBox.IsChecked;

