user2584960
user2584960

Reputation: 695

Is it possible to override a control's event handler globally?

I have about 3000 checkboxes that I would like to have their "PreviewMouseLeftButtonDown" event handled differently. Is it possible to override the default event handler for all checkboxes globally?

Upvotes: 1

Views: 778

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564413

Checkbox.Checked is a Routed Event. This means you can assign a common event handler within a parent of the tree, and handle the events "globally" however you choose.

For details, see Routed Events Overview, in particular, the section titled "Singular Handler Attachment Points", which deals with this scenario.

Upvotes: 1

Related Questions