我在父视图中有一个simpleButton,我希望将此按钮与子视图模型中的方法绑定。
_fluentApi.BindCommand(simpleButton , x => x.SaveMessage());
答案 0 :(得分:0)
DevExpress MVVM Fluent API支持绑定到嵌套属性/命令:
// ViewModel
public class ParentViewModel {
public ParentViewModel() {
Child = ChildViewModel.Create();
}
public virtual ChildViewModel Child {
get;
protected set;
}
}
public class ChildViewModel{
public static ChildViewModel Create() {
return DevExpress.Mvvm.POCO.ViewModelSource.Create<ChildViewModel>();
}
public void Save(){
// ...
}
}
// View
var fluentApi = mvvmContext.OfType<ParentViewModel>()
fluentApi.BindCommand(simpleButton , x => x.Child.Save());