mvvm - 禁用给定 V/VM 对的 Caliburn.Micro View/ViewModel 绑定(bind)约定

标签 mvvm datatemplate caliburn.micro

我喜欢 Caliburn Micro,但我在这里遇到了一些困难:

我想手动为给定的 ViewModel 子类型定义一个 DataTemplate,但我不知道如何禁用基于名称的自动约定。

最佳答案

来自 "All About Conventions(Caliburn.Micro")文档:

Should you decide that you don’t like the behavior of the ViewModelBinder (more details below), it follows the same patterns as the above framework services. It has several Funcs you can replace with your own implementations, such as Bind, BindActions and BindProperties. Probably the most important aspect of customization though, is the ability to turn off the binder’s convention features. To do this, set ViewModelBinder.ApplyConventionsByDefault to false. If you want to enable it on a view-by-view basis, you can set the View.ApplyConventions attached property to true on your View. This attached property works both ways. So, if you have conventions on by default, but need to turn them off on a view-by-view basis, you just set this property to false.

关于mvvm - 禁用给定 V/VM 对的 Caliburn.Micro View/ViewModel 绑定(bind)约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26715868/

相关文章:

C# WPF MenuItem 自定义模板

wpf - 命令绑定(bind)到 DataTemplate 内的按钮不起作用

c# - 使用带有 IoC 容器的 Caliburn.Micro MVVM 框架的 Bootstrap 设计模式

c# - 使用 MVVM 单击 DataGrid 单个单元格行和列

c# - MVVM:ViewModel 和业务逻辑连接

c# - 在代码隐藏中将参数传递给 RelayCommand

mvvm - 我的用户控件和 ViewModel 之间的绑定(bind)

c# - 来自字符串的 IValueConverter

c# - 如何使用 WinRT Caliburn.Micro 将参数传递给导航 View 模型?

wpf - Caliburn.Micro 消息冒泡跳过控件