How do I load controls in different ContentControls of a Shell using CaliburnMicro

百般思念 提交于 2019-11-28 00:48:29

问题


By default when you use "ActivateItem(new Control());" your control is loaded into a ContentControl which with the name ActiveItem, fro example. . If I have multiple content controls on my page how would I load controls into them whilst retaining the ability to use the default functionality of being able to load controls into the the active item control.

for example I want to have a login control to be loaded into the Login ContentControl, and when a user successfully login I want a new control to be loaded into the ActiveItem ContentControl.

Thanx in advance.


回答1:


If the ViewModel that gets binded to the UI contains a property with the name that matches a content control. The Content control view automatically gets resolved the the view supported by this property, provided this property itself is a ViewModel type and has been registed with Ioc container. For example

<ContentControl x:Name="LoginStatus"></ContentControl>

If there is a property LoginStatus on the main ViewModel (LoginStatus property itself is a ViewModel). The content control would correctly get rendered with the appropriate view.




回答2:


You should have a look at Screen Conductors. See here.



来源:https://stackoverflow.com/questions/6185675/how-do-i-load-controls-in-different-contentcontrols-of-a-shell-using-caliburnmic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!