Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsHitTestVisible set to false on parent element ignores IsHitTestVisible set to true for child elements #16066

Open
SKeehnen opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@SKeehnen
Copy link

SKeehnen commented Jun 19, 2024

Describe the bug

When setting IsHitTestVisible set to false on a parent element, any child that has set IsHitTestVisible to true is ignored and will not respond to for example a Tapped event.

To Reproduce

Add the following to an axaml file:

<StackPanel VerticalAlignment="Stretch" Background="Yellow"  IsHitTestVisible="False">
     <StackPanel x:Name="StackBottom" VerticalAlignment="Bottom" Background="Black" IsHitTestVisible="True" Tapped="StackBottom_Tapped">
        <TextBlock Text="Try to click me"></TextBlock>
    </StackPanel>
</StackPanel>

Add the following to the axaml.cs file:

private void StackBottom_Tapped(object sender, TappedEventArgs e) {
    System.Diagnostics.Debug.WriteLine("I'm Tapped");
}

Expected behavior

All child elements of an element that has set IsHitTestVisible to false should be ignored for touch events, unless a child element has set IsHitTestVisible to true.
In the example above the function StackBottom_Tapped should be called when clicking on the StackPanel called StackBottom.

Avalonia version

11.1.0-rc1

OS

Windows, Linux

Additional context

No response

@SKeehnen SKeehnen added the bug label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant