How to set InputTransparent as true for parent, not for children

Viewed 1936

I am having one stacklayout and one button inside that. I want to click through that stacklayout, and also that button click.

I tried setting InputTransparent as true for StackLayout and then setting same as false for button. It did not work. Whatever applied at parent level is set to all children inside it.

<StackLayout InputTransparent="True">
    <Button Text="Submit" InputTransparent="False"/>
</StackLayout>

I expect button to be clicked, as well as element behind StackLayout should be clickable.

3 Answers

Use CascadeInputTransparent.

<StackLayout InputTransparent="True" CascadeInputTransparent="False">
   <Button Text="Submit"/>
</StackLayout>

InputTransparent gets or sets a value indicating whether this element should be involved in the user interaction cycle. You set StackLayout InputTransparent to true, which means "don't allow this view to receive any input". If you set that on a parent view then none of its children should receive touches either.

Related