user1752611
user1752611

Reputation: 11

Mouse button event on a disabled checkbox in C#/WPF

I am having a tricky problem, I need to do some action when a user is making a right-click on a checkbox, but this checkbox can be disabled (IsEnabled="False") for business logic reason. The problem is that even the previewMousDown event is not raised when the CheckBox is disabled.

Any idea how to solve this problem?

Upvotes: 1

Views: 1683

Answers (2)

Klaus78
Klaus78

Reputation: 11926

surround your CheckBox with a ContentControl and handle that event on the ContentControl

Upvotes: 3

Fredrik Claesson
Fredrik Claesson

Reputation: 629

You could have a MouseDown eventhandler on a control higher up in the VisualTree and use HitTest to figuer out if your checkbox would be "RightClicked"

http://msdn.microsoft.com/en-us/library/ms752097.aspx

Upvotes: 4

Related Questions