开发者

Flow of control in WPF application

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 popu开发者_如何学JAVAlates the model with it.

Who creates this class?

Which is the best way to monitor for POSView readiness to "eat data"?

Thank you.


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:

public int Value
{
  get
  {
    if (!isLoaded)
    {
       LoadData();
    }

    return loadedValue;
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜