title: MVVM & Serialization - How do I access the instances of classes?
body: <p>I'm trying to learn how to serialize objects using the MVVM pattern. I have a <code>MainViewModel</code> which I would like to serialize. The serializer needs an instance of <code>MainViewModel</code> which should be created in my <code>MainView</code>, but I can't figure out how to access it. What are my options here? What would be the best route for me to take to manage to serialize my ViewModels (or Models for that matter)? Would making classes <code>static</code> help or would that just break the pattern (From what I've seen MVVM doesn't seem to be too big on <code>static</code>? </p>
  
  <p>I am an inexperienced programmer (especially when it comes to MVVM), but I really am trying here I'm just at a loss at this point. I would really appreciate any help anybody could give me in figuring out how to serialize my ViewModels and Models.</p>
  
  <pre><code>"&lt;Window.DataContext&gt;
      &lt;local:MainViewModel/&gt;
   &lt;/Window.DataContext&gt;
  </code></pre>
  
  <p>EDIT: More code</p>
  
  <pre><code>    private void SaveGameExecute()
      {
          ObjectSerializer&lt;MainViewModel&gt; objSerializer = new ObjectSerializer&lt;MainViewModel&gt;();
          objSerializer.SaveSerializedObject(this, "Save.sav");
      }
  
      private void LoadGameExecute()
      {
          ObjectSerializer&lt;MainViewModel&gt; objSerializer = new ObjectSerializer&lt;MainViewModel&gt;();
          /*****/ = objSerializer.GetSerializedObject("Save.sav");
      }
  </code></pre>
  
  <p>EDIT: Regardless of what it is I need to serialize, can anybody please give me some advice on how to do this using MVVM? If it's models I need to serialize, I still don't know how to access the particular instances of them. If anybody who has experience with serializing MVVM projects, please give me some guidelines of what to do. Without knowing how to locate the instances of the models/viewmodels/etc I don't really know what to do.</p>