如何为多个ViewModel实现单个视图 或单个ViewModel用于MvvmCross中的多个视图
谢谢
答案 0 :(得分:0)
public partial class App : MvxApplication
{
protected override void RegisterSetup()
{
//this.RegisterSetupType<MvxWpfSetup<Core.App>>();
// 注册自定义设置
this.RegisterSetupType<Setup>();
}
}
public class Setup : MvxWpfSetup
{
protected override IMvxApplication CreateApp()
{
return new Core.App();
}
protected override void InitializeViewLookup()
{
base.InitializeViewLookup();
// 自定义 视图& VM之间的关系
var container = Mvx.IoCProvider.Resolve<IMvxViewsContainer>();
var viewModelViewLookup = new Dictionary<Type, Type>()
{
{ typeof(NativeViewModel), typeof(Test) },
{ typeof(NestedChildViewModel), typeof(Test) }
};
//container.Add(typeof(NativeViewModel), typeof(Test));
//container.Add(typeof(NestedChildViewModel), typeof(Test));
container.AddAll(viewModelViewLookup);
}
}