亲子模型互动
是否可以在 caliburn.micro 中设置类似 wpf 窗口所有者的内容?
我有父视图模型,从这个模型中我使用以下方法打开子屏幕 {视图模型}:
public IEnumerable<IResult> Open()
{
yield return new ShowWindow("ChatScreen")
.InitializeWith(_service
.DetailData(Account, _selectedFriend.Value.Nick),
AvatarImage);
}
此方法创建一个新的 WPF 窗口 - 子屏幕并使用一些变量初始化子视图模型。
我想设置像这样的 CHILD_SCREEN.PARENT = PARENT_VIEW_MODEL。
如果我关闭父视图模型,我希望实现它也关闭所有子模型。
另外,我如何检查屏幕(在我的情况下 WPF 窗口)是否从主视图模型处于活动/非活动状态?
is it possible set something like wpf window owner in caliburn.micro ?
I have PARENT VIEW MODEL, from this model I open CHILD SCREEN {VIEW MODEL} with this method:
public IEnumerable<IResult> Open()
{
yield return new ShowWindow("ChatScreen")
.InitializeWith(_service
.DetailData(Account, _selectedFriend.Value.Nick),
AvatarImage);
}
This method create a new WPF WINDOW - CHILD SCREEN and initialize CHILD VIEW MODEL with some variables.
I would like set something like this CHILD_SCREEN.PARENT = PARENT_VIEW_MODEL.
I would like achieve if I close PARENT VIEW MODEL that it close also all CHILD MODELS.
Also it exist way how can I check if screen, in my situation WPF window, is active/inactive from MAIN VIEW MODEL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为此编写基础架构。我假设 ShowWindow 使用 Caliburn.Micro 的 WindowManager 来显示窗口?在这种情况下,您需要维护对每个打开的窗口的引用。这种父/子关系要求只是为了在父项关闭时关闭所有子项吗?一种选择是实现您自己的 Conductor 类型(维护打开的窗口列表)和您自己的 IScreen/Screen 类型(维护父/子关系状态)。
You'll need to write the infrastructure for this. I'm assuming ShowWindow is using Caliburn.Micro's WindowManager to display the window? In which case, you'll need to maintain a reference to each window that is open. Is this parent/child relationship requirement just for the purpose of closing all children when the parent is closed? One option would be to implement your own Conductor type which maintains a list of open windows, and your own IScreen/Screen types which maintain parent/child relationship state.