AutowirePartialView Bindable Property已经被弃用,可以使用AutoFac来绑定Bindable Property。以下是绑定Bindable Property的示例代码:
public class SomeViewModel : BindableObject
{
// Bindable Property
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(
"ItemsSource", typeof(IEnumerable), typeof(SomeViewModel), null, BindingMode.Default, null, null, null, null);
public IEnumerable ItemsSource
{
get => (IEnumerable)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
// AutoFac注册Bindable Property
public static void Register(ContainerBuilder builder)
{
builder.RegisterType()
.PropertiesAutowired()
.OnActivated(x =>
{
// 设置Bindable Property
x.Instance.ItemsSource = new List { "item1", "item2", "item3" };
});
}
}