
[英]Xamarin.Forms Timepicker IsVisible property vs. Custom Renderer
[英]Control property doesn't exist in a xamarin forms custom renderer
我正在android和uwp上创建自定义渲染器。 事情进展顺利。 但是,谈到Android。 无法识别Control属性,它说:“在当前上下文中无法识别名称'Control'”。
这是我写的代码:
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var gradientBoxView = Element as GradientBoxView;
var linearGradient = gradientBoxView.Color;
//colors
var nativeColors = linearGradient.LinearGradientStops.Select(gs => gs.Color).ToArray();
int[] colors = new int[nativeColors.Count()];
for (int i = 0; i < nativeColors.Length; i++)
colors[i] = nativeColors[i].ToAndroid();
var gradient = new GradientDrawable(Utils.AndroidUtils.ToGradientDrawableFlow(linearGradient.Flow), colors);
Control.SetBackgroundDrawable(gradient);
}
有什么帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.