WPF 应用程序中的控制流
在 WPF 应用程序中,我有 MainWindow : Window
加载 POSView : UserControl
。
当主窗口加载时,POSView 必须自动向用户显示一些数据。
POSView 绑定到其 ViewModel 类属性,而 ViewModel 类属性又绑定到模型属性。
我正在尝试遵循 MVVM 模式。我的问题是谁应该用数据填充我的模型。
显然,类的某个对象监视 MainWindow 或 POSView 事件(以了解它何时已加载并准备好显示数据),此时从远程 WCF 服务读取数据(在我的例子中)并用它填充模型。
谁创建了这个类?
监控 POSView 准备“吃掉数据”的最佳方法是什么?
谢谢。
In WPF application I have MainWindow : Window
which loads a POSView : UserControl
.
POSView has to automatically show some data to an user when main window loads.
POSView is bound to its ViewModel class properties, which in turn is bound to a model properties.
I am trying to follow the MVVM pattern. My question is who should populate my model with data.
Apparently some object of a class, that monitors for MainWindow or POSView events (to know when it has been loaded and ready to display data) and at this point reads data from a remote WCF service (in my case) and populates the model with it.
Who creates this class?
Which is the best way to monitor for POSView readiness to "eat data"?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当需要显示数据时,您的控件将从 ViewModel 的属性中获取数据。因此,您可以在属性访问器中使用延迟加载。例如:
Your control will get data from ViewModel's properties when they'll be needed to display. So you may use lazy loading in property accessors. For example: