#679 – Setting IsHitTestVisible to False Prevents Interaction with Controls

When you set the IsHitTestVisible property to false for a user interface element, it will no longer respond to mouse input and will not fire mouse-related events.

With IsHitTestVisible set to false, you therefore can’t use the mouse to interact with a user interface element at all.  In the example below, we can’t use the mouse to give the elements focus or to click or select any of them.

        <Button Content="You can't Click this" HorizontalAlignment="Center" Margin="5" Click="Button_Click_1"
        <TextBox Text="You can't Edit this" HorizontalAlignment="Center" Margin="5"
        <CheckBox Content="You can't Check this" HorizontalAlignment="Center" Margin="5"
        <ComboBox HorizontalAlignment="Center" Margin="5" SelectedIndex="0"
                <ComboBoxItem Content="You can't Select this"/>
                <ComboBoxItem Content="Or this"/>

Notice, however, that you can still interact with the elements using the keyboard.  For example, you can tab to the Button and then press Enter to trigger its Click event.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #679 – Setting IsHitTestVisible to False Prevents Interaction with Controls

  1. Pingback: Dew Drop – October 30, 2012 (#1,432) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: