【问题标题】:BackgroundColor in control blocked click控件中的 BackgroundColor 阻止了单击
【发布时间】:2015-12-25 20:32:04
【问题描述】:

我有 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 透明 - 抓住点击。当 ContentView 不透明 - 跳过点击到 Frame。

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

【问题讨论】:

    标签: xamarin xamarin.forms xamarin-studio


    【解决方案1】:

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

    【讨论】:

    • 对于第一个实施例,我设置属性“BackgroundColor = Color.FromRgba(1,1,1,0);”对于第二个实施例,我设置属性“InputTransparent = true”。完美的!谢谢!
    猜你喜欢
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 2017-11-22
    相关资源
    最近更新 更多