Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could register a "lazy wrapper" instead. Such a wrapper implements the same interface and can be instantiated immediately, but will internally postpone the creation of the actual component that does the work. Take a look at ploeh's example of a <a href="http://blog.ploeh.dk/2010/01/20/RebuttalConstructorOverinjectionAntipattern.aspx" rel="nofollow">LazyOrderShipper</a> or <a href="http://blog.ploeh.dk/2010/01/20/EnablingDIForLazyComponents.aspx" rel="nofollow">LazyOrderShipper2</a>.</p> <p><strong>edit:</strong> If I understand correctly, you're just trying to connect your views to your viewmodels, MVVM-style. I prefer to let the container handle viewmodel construction, but to do the view construction and viewmodel wiring myself. My start-up code woul look like this:</p> <pre><code>var mainViewModel = container.Get&lt;MainViewModel&gt;(); var mainView = new MainView(mainViewModel); Application.Run(mainView); </code></pre> <p>And inside the <code>MainView</code> constructor I'd take care of child controls which require their own viewmodel:</p> <pre><code> public MainView(MainViewModel viewModel) { // link "subviews" to "subviewmodels" this.SomeChildControl.ViewModel = viewModel.SomeChildViewModel; // normal MVVM property wiring viewModel.TitleChanged += delegate { this.Text = viewModel.Title; }; ... } </code></pre> <p>If you strictly follow the MVVM approach, then you should not have to register any view with the container. Anything that "needs to talk to the view" really needs to talk to underlying viewmodel instead. (Things get more interesting when you want to allow for pluggable views in tabbed interface or docked window GUI, but that's another story.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload