Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 370
shivanju0801 Avatar asked Dec 22 '22 22:12

shivanju0801


2 Answers

Layouts have a property CascadeInputTransparent. When true, child views inherit their parent's input transparency. When false, child views do not inherit the input transparency of the layout where Cascade is set.

https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.layout.cascadeinputtransparent?view=xamarin-forms

like image 132
Max Hampton Avatar answered Jan 08 '23 15:01

Max Hampton


Use CascadeInputTransparent.

<StackLayout InputTransparent="True" CascadeInputTransparent="False">
   <Button Text="Submit"/>
</StackLayout>
like image 23
thenewhd Avatar answered Jan 08 '23 15:01

thenewhd