#680 – IsHitTestVisible Applies to All Child Elements

If you set the IsHitTestVisible  property of a container element to false, it will turn off hit testing for all elements within that container.

Even if a child element sets its own IsHitTestVisible property to true, it will still be hidden from hit testing.  The false value set at the container level applies to all child elements, no matter what value they set.

    <StackPanel IsHitTestVisible="False">
        <Button Content="You can't Click this" HorizontalAlignment="Center" Margin="5" Click="Button_Click_1"/>
        <Button Content="You can't even Click this" HorizontalAlignment="Center" Margin="5" Click="Button_Click_2"
                IsHitTestVisible="True"/>
    </StackPanel>

Advertisement