[英]Access parent window control WPF
I have two windows: 我有两个窗口:
ListItemWindow
ListItemWindow
(parent) that contain ocItems as ObservableCollection (父)包含ocItems作为ObservableCollection
DetailItemWindow
DetailItemWindow
I called DetailItemWindow from ListItemWindow (DetailItemWindow.ShowDialog()) 我从ListItemWindow(DetailItemWindow.ShowDialog())调用了DetailItemWindow
From DetailItemWindow How can I access to ocItems ? 从DetailItemWindow如何访问ocItems?
Why not pass parent Window in constructor to child Window? 为什么不将构造函数中的父窗口传递给子窗口? It doesn't violate MVVM at all, Views can know each other if they're dependant.
它根本不违反MVVM,如果视图相互依赖,则视图可以彼此了解。
private ListItemWindow parent;
public DetailItemWindow(ListItemWindow window){
this.parent = window;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.