gpt4 book ai didi

c# - 弃用绑定(bind),新的方法是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 19:44:01 24 4
gpt4 key购买 nike

此绑定(bind)已弃用,您不应再使用泛型。我应该怎么做?

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);
});

关于c# - 弃用绑定(bind),新的方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48665234/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com