WPF button only works when clicking on content? | Programming, .NET, Silverlight & More

WPF button only works when clicking on content?

Using c# windows form, hosting a wpf user control, the buttons on the user control only allow a click on the content of the button, but not on the button’s blank space. Is there a property that changes this?

Have you got the click handler on the content rather than the button? I tend to code buttons as:

<Button Content="Click Me!" Clicked="OnClickMeClicked"/>

You might have:

<Button><TextBlock Text="Click Me!" MouseLeftButtonDown="OnClickMeClicked"/></Button>

(Although that seems unlikely, but it’s possible.)

I’m always caught out by windows that don’t have a fill, even a transparent fill, associated with them. If it isn’t painted, it isn’t clickable!

No TweetBacks yet. (Be the first to Tweet this post)

One Response

  1. WaMSie Says:

    Have you got the click handler on the content rather than the button? I tend to code buttons as:

    <Button Content="Click Me!" Clicked="OnClickMeClicked"/>

    You might have:

    <Button><TextBlock Text="Click Me!" MouseLeftButtonDown="OnClickMeClicked"/></Button>

    (Although that seems unlikely, but it’s possible.)

    I’m always caught out by windows that don’t have a fill, even a transparent fill, associated with them. If it isn’t painted, it isn’t clickable!
    References :

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.