Events

jwh

Well-known member
Joined
Aug 18, 2006
Messages
155
Programming Experience
3-5
This could just be me not quite getting a grasp of routed events yet, but I can't seem to figure this out...



I'm trying to fire an event when a label is clicked. I could do this without an issue in winforms.

However in WPF, I get the error: 'Click' is not an event of 'System.Windows.Controls.Label'

This make little sense to me, and therfore the only way I can see through this at the moment is to put the label on top of a button, or use a button that just looks like a label.

This seems very restrictive for a UI development that is supposed to give us more freedom than ever before!
 
Clicking a label

While WPF enables a number of great new things. Not everything is perfect, or exactly like we are used to. We love to hear what things you run into that caused you pause.

We didn't expose a Click event on all controls...using a button is one way of getting Click functionality.

If you are just trying to change focus to another element when you click on a Label, you can set the Target property to the element that you want focused when somebody Clicks on the label (or uses the accelerator keys for the label.)

Label in MSDN

Thanks, Rob Relyea
Program Manager, WPF Team
robrelyea.com | /blog | /wpf | /xaml
 
Back
Top