简体   繁体   English

Xamarin.Forms使非透明叠加层不可单击

[英]Xamarin.Forms make non-transparent overlay not clickable

I have this XAML 我有这个XAML

<ContentPage>
     <RelativeLayout>
          <ScrollView />
          <Button />
          <local:ModalActivityIndicator />
     </RelativeLayout>
</ContentPage>

This indicator is relative to its parent and covers it's full width and height. 该指标是相对于其父指标的,涵盖了指标的整个宽度和高度。
The indicator has this binding: this.SetBinding (IsVisibleProperty, "IsBusy"); 指示器具有以下绑定: this.SetBinding (IsVisibleProperty, "IsBusy");
It is showing precisely how I want it, but I can still tap on items in the ScrollView and on the Button . 它精确地显示了我想要的方式,但是我仍然可以点击ScrollViewButton上的项目。 When the indicator shows, the InputTransparent property is set to false . 当指示器显示时, InputTransparent属性设置为false

How can I prevent this? 我该如何预防?

I found a rather acceptable workaround for this. 我为此找到了一个可以接受的解决方法。
If you add a TapGestureRecognizer to the ModalActivityIndicator , all input will be caught by the overlay and no interaction will be transferred to the underlying elements. 如果将TapGestureRecognizer添加到ModalActivityIndicator ,则所有输入都将被叠加捕获,并且不会有任何交互传递到基础元素。

GestureRecognizers.Add(new TapGestureRecognizer());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM