且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

取决于ContentControl(Caliburn.Micro)的不同视图

更新时间:2023-02-09 19:55:42

是的,有可能。

使用 cal:View.Context 附加属性,然后为指定的上下文命名视图,例如 YourNamespace.Something.ContextView (从视图模型名称中删除 ViewModel,添加一个点,以及Context属性的值)。

Use cal:View.Context attached property and then name your view for the specified context like YourNamespace.Something.ContextView (remove "ViewModel" from your view model name, add a dot, and the value of Context property).

那样,您甚至可以将多个视图绑定到一个视图模型。

By that, you can even bind several views to one view model.

示例:

<ContentControl x:Name="Toolbar" cal:View.Model="{Binding ActiveItem}" cal:View.Context="Toolbar" />

您可以看到工作示例此处(摘自 CoProject 示例应用程序,第9部分)。

You can see working example here (from CoProject sample application, part 9).