从
this链接.
false if the element should receive input; true if element should not receive input and should,instead,pass inputs to the element below. Default is false.
我想要的是,不允许Entry字段接收来自用户的输入.
InputTransparent = true在iOS中运行良好但在Android中不起作用,它仍然允许用户提供输入.
我尝试过IsEnabled = false,但这会改变我的Entry字段的外观,我不希望这样.
这是某种错误吗?
解决方法
InputTransparent不适用于Android.我为StackLayout创建了简单的渲染:
在PCL项目中:
public class StackLayoutAdd :StackLayout
{
}
在Android项目中:
[assembly: ExportRenderer(typeof(StackLayoutAdd),typeof(StackLayoutAddCustom))]
.....
public class StackLayoutAddCustom : VisualElementRenderer<StackLayout>
{
public override bool dispatchTouchEvent(MotionEvent e)
{
base.dispatchTouchEvent(e);
return !Element.InputTransparent;
}
}
我在我的xaml中使用它:
<StackLayoutAddCustom InputTransparent={Binding IsReadOnly}>
<Editor />
....
</StackLayoutAddCustom>
这是儿童控制的工作.