title: Where to bind the ViewModel to the View?
body: <p>I work on a project(6 pages) target on Windows Phone 7.5 and above. I don't do the pure MVVM model, since handle the navigation event and querystrings is such a pain, and I decide to learn it one by one, and finish the project first :P</p>
  
  <p>Since I am new new to MVVM, I decide not to use MVVM Light, writes all the boilerplate codes myself.
  When I finish coding each part, I face a problem.</p>
  
  <p>Where to bind the viewmodel is the most efficient. I read a lot and conclude the points below.</p>
  
  <ol>
  <li><p>create the Model instance in the App.xaml.cs as a property, and make the binding in the codebehind of the view.(This is how the official Data Bound App example does.) But when facing a lots of view (6 pages etc), this may be a problem.</p>
  
  <pre><code>public partial class App : Application
  {
      private static MainViewModel viewModel = null;
  
      /// &lt;summary&gt;
      /// A static ViewModel used by the views to bind against.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;The MainViewModel object.&lt;/returns&gt;
      public static MainViewModel ViewModel
      {
          get
          {
              // Delay creation of the view model until necessary
              if (viewModel == null)
                  viewModel = new MainViewModel();
  
              return viewModel;
          }
      }
  }
  </code></pre></li>
  <li><p>Make a new instance of the viewmodel as a global variable in the code behind of the view. So I can use it through out the view. (as above, I don't do the pure MVVM)</p></li>
  <li><p>In the code behind, in the constructor, do the bindings once.</p>
  
  <pre><code>public MainPage()
  {
      InitializeComponent();
  
      myViewModel vm = new myViewModel();
      DataContext = vm;
  }
  </code></pre></li>
  </ol>
  
  <p>I read mvvm light which use a ViewModelLocator as a central station. But avoid to use mvvm light, where to bind the viewmodel do you guys think is the best?</p>