无法创建 Xamarin Forms Picker 自定义渲染器
Can't create Xamarin Forms Picker custom rendere
您好,我很容易为 Forms Entry 控件创建自定义呈现器,但是当我尝试为 Picker 创建一个时,我收到此错误:
Error CS0115: `Punteam.iOS.PunteamPickerRederer.OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.Picker>)' is marked as an override but no suitable method found to override (CS0115) (Punteam.iOS)
这是我在 Forms 项目上的代码:
using System;
using Xamarin.Forms;
namespace Punteam
{
public class PunteamPicker : Picker
{
}
}
在 IOS 项目上:
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform;
using Punteam;
using Punteam.iOS;
using UIKit;
using EventKitUI;
[assembly: ExportRenderer (typeof(PunteamPicker), typeof(PunteamPickerRederer))]
namespace Punteam.iOS
{
public class PunteamPickerRederer : PunteamPicker
{
protected override void OnElementChanged (ElementChangedEventArgs<Picker> e)
{
/* base.OnElementChanged (e);
this.Control.TextAlignment = MonoTouch.UIKit.UITextAlignment.Center;
this.Control.TextColor = UIColor.White;
this.Control.BackgroundColor = UIColor.Clear;
this.Control.BorderStyle = UITextBorderStyle.RoundedRect;
this.Layer.BorderWidth = 1.0f;
this.Layer.CornerRadius = 4.0f;
this.Layer.MasksToBounds = true;
this.Layer.BorderColor = UIColor.White.CGColor;*/
}
}
}
有人知道为什么我会收到此错误吗?
public class PunteamPickerRederer : PunteamPicker
应该是
public class PunteamPickerRederer : PickerRenderer
您好,我很容易为 Forms Entry 控件创建自定义呈现器,但是当我尝试为 Picker 创建一个时,我收到此错误:
Error CS0115: `Punteam.iOS.PunteamPickerRederer.OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs<Xamarin.Forms.Picker>)' is marked as an override but no suitable method found to override (CS0115) (Punteam.iOS)
这是我在 Forms 项目上的代码:
using System;
using Xamarin.Forms;
namespace Punteam
{
public class PunteamPicker : Picker
{
}
}
在 IOS 项目上:
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform;
using Punteam;
using Punteam.iOS;
using UIKit;
using EventKitUI;
[assembly: ExportRenderer (typeof(PunteamPicker), typeof(PunteamPickerRederer))]
namespace Punteam.iOS
{
public class PunteamPickerRederer : PunteamPicker
{
protected override void OnElementChanged (ElementChangedEventArgs<Picker> e)
{
/* base.OnElementChanged (e);
this.Control.TextAlignment = MonoTouch.UIKit.UITextAlignment.Center;
this.Control.TextColor = UIColor.White;
this.Control.BackgroundColor = UIColor.Clear;
this.Control.BorderStyle = UITextBorderStyle.RoundedRect;
this.Layer.BorderWidth = 1.0f;
this.Layer.CornerRadius = 4.0f;
this.Layer.MasksToBounds = true;
this.Layer.BorderColor = UIColor.White.CGColor;*/
}
}
}
有人知道为什么我会收到此错误吗?
public class PunteamPickerRederer : PunteamPicker
应该是
public class PunteamPickerRederer : PickerRenderer