Autofac如何绑定BindableProperty?
创始人
2024-11-12 11:30:35
0

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

相关内容

热门资讯

两分钟了解(aapokeR)外... 两分钟了解(aapokeR)外挂透明挂辅助下载(透视)2025新版教程(2026已更新)(哔哩哔哩)...
第三分钟了解(众合推扑克)外挂... 第三分钟了解(众合推扑克)外挂透明挂辅助软件(透视)揭秘教程(2025已更新)(哔哩哔哩);第三分钟...
5分钟了解(菠萝德州app)外... 5分钟了解(菠萝德州app)外挂透明挂辅助安装(透视)透明教程(2026已更新)(哔哩哔哩);5分钟...
一分钟了解(AAPOKEr)软... 一分钟了解(AAPOKEr)软件透明挂辅助软件(透视)wpk教程(2020已更新)(哔哩哔哩);wp...
2分钟了解(德扑手机上)软件透... 2分钟了解(德扑手机上)软件透明挂辅助app(透视)安装教程(2021已更新)(哔哩哔哩);德扑手机...
5分钟了解(德州poker)黑... 5分钟了解(德州poker)黑科技透明挂辅助代打(透视)透明教程(2026已更新)(哔哩哔哩);最新...
第3分钟了解(扑克世界app)... 第3分钟了解(扑克世界app)黑科技透明挂辅助ai(透视)2025新版教程(2026已更新)(哔哩哔...
四分钟了解(WPK控制)外挂透... 四分钟了解(WPK控制)外挂透明挂辅助插件(透视)AI教程(2026已更新)(哔哩哔哩);人气非常高...
第1分钟了解(wepoke德州... 第1分钟了解(wepoke德州扑克)外挂智能ai辅助软件(透视)必赢方法(2022已更新)(哔哩哔哩...
1分钟了解(WPK控制)外挂智... 1分钟了解(WPK控制)外挂智能ai辅助安装(透视)可靠教程(2020已更新)(哔哩哔哩);致您一封...