此绑定已被弃用,您不应再使用泛型。我该怎么办?

BindableProperty.Create<ImageGallery, IList>(
                view => view.ItemsSource,
                default(IList),
                BindingMode.TwoWay,
                propertyChanging: (bindableObject, oldValue, newValue) => {
                    ((ImageGallery)bindableObject).ItemsSourceChanging();
                },
                propertyChanged: (bindableObject, oldValue, newValue) => {
                    ((ImageGallery)bindableObject).ItemsSourceChanged(bindableObject, oldValue, newValue);
                }
            );

最佳答案

您可以将类型定义为Create()方法的参数,如下所示:

public ImageGallery MyImageGallery
{
    get { return (ImageGallery)GetValue(MyImageGalleryProperty); }
    set { SetValue(MyImageGalleryProperty, value); }
}

public static BindableProperty MyImageGalleryProperty = BindableProperty.Create(nameof(MyImageGallery), typeof(ImageGallery), typeof(IList), default(IList), BindingMode.TwoWay,
    propertyChanging: (bindableObject, oldValue, newValue) =>
    {
        ((ImageGallery) bindableObject).ItemsSourceChanging();
    },
    propertyChanged: (bindableObject, oldValue, newValue) =>
    {
        ((ImageGallery) bindableObject).ItemsSourceChanged(bindableObject, oldValue, newValue);
    });

07-25 20:33