我有这个课:
public class ExtSwitch : Switch
{
public static readonly
BindableProperty SwitchOutsideOvalColorProperty =
BindableProperty.Create(nameof(SwitchOutsideOvalColor),
typeof(Color),
typeof(ExtSwitch),
Color.Default,
propertyChanged: HandleOutsidePropertyChanged);
public Color SwitchOutsideOvalColor {
get => (Color)GetValue(SwitchOutsideOvalColorProperty);
set => SetValue(SwitchOutsideOvalColorProperty, value); }
public void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
}
,并且我正在尝试创建一个iOS版本,以响应HandleOutsidePropertyChanged()。我尝试过:
[assembly: ExportRenderer(typeof(ExtSwitch), typeof(ExtSwitchRenderer))]
namespace Japanese.iOS
{
class ExtSwitchRenderer : SwitchRenderer
{
public override void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
}
}
但是我收到一条错误消息,提示找不到合适的方法来覆盖。
答案 0 :(得分:2)
HandleOutsidePropertyChanged是ExtSwitch的一种方法,ExtSwitchRenderer继承自SwitchRenderer。
答案 1 :(得分:0)
代替:
public void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
您需要执行此操作。
public void HandleOutsidePropertyChanged(BindableObject bindable, Color oldValue, Color newValue)
{
var a = 99;
}
然后您可以覆盖。