控件中的 BackgroundColor 阻止了单击

BackgroundColor in control blocked click

我有 FrameGrid 内容。当我将 contentWiew(含内容)添加到 Grid 时,有两个选项:

1. 如果 contentWiew 有 BackgroundColor = "Transparent" 那么当我点击contentWiew 按下发生在 Frame 中(contentWiew 跳过它)。

2. 如果 contentWiew 有 BackgroundColor = NotTransparent (Red,Yellow) 然后当我点击 contentWiew 按下发生在 contentWiew ().

部分代码:

        Label mainText = new Label {  Text = "TestText", FontSize = 14 };
        var contntView = new ContentView () { BackgroundColor = Color.Transparent , HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start };
        contntView.Content =  mainText;
        mainGrid.Children.Add (contntView,0,1);

我需要精确地进行周转 =) 当 ContentView 为 Transparent - 捕捉点击。当 ContentView 不透明时 - 跳过点击到框架。

无论 BackgroundColor 如何控制这个过程?

您可以使用任何视图的 InputTransparent 属性 部分控制此过程。如果设置为 true,视图将对触摸事件透明。