[英]Binding in skiasharp xamarin forms
我想绑定skpaint color属性,因为skiasharp表单库没有内置的绑定。有人可以演示如何实现这一点,或者至少可以指出我的方向。
感谢xamarin论坛提供的AlexP,我可以将自己的可绑定属性添加到任何控件中,这非常容易
public class BindableSKCanvasView : SKCanvasView
{
public static readonly BindableProperty ColorProperty =
BindableProperty.Create("Color", typeof(SKColor), typeof(BindableSKCanvasView),defaultValue:SKColors.Black, defaultBindingMode: BindingMode.TwoWay, propertyChanged: RedrawCanvas);
public SKColor Color
{
get => (SKColor)GetValue(ColorProperty);
set => SetValue(ColorProperty, value);
}
private static void RedrawCanvas(BindableObject bindable, object oldvalue, object newvalue)
{
BindableSKCanvasView bindableCanvas = bindable as BindableSKCanvasView;
bindableCanvas.InvalidateSurface();
}
}
这是论坛链接供参考
https://forums.xamarin.com/discussion/122312/binding-in-skiasharp-xamarin-forms
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.