title: ViewModel properties for properties of nested classes inside the model
body: <p>I have an application following the MVVM pattern, that has to serialize XML files. As some of the XML attributes are nested, I've created nested classes inside my Model, like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class OPER_FILE
  {
      public UNB unb { get; set; }
      public OPER oper { get; set; }    //nested class, level 1
  
      public OPER_FILE()
      {
          unb = new UNB();
          oper = new OPER();
      }
  }
  
  public class OPER
  {
      public UNH unh { get; set; }    //these are all nested classes, level 2
      public UVT uvt { get; set; }
      public VIN vin { get; set; }
  
      public OPER()
      {
          unh = new UNH();
          uvt = new UVT();
      }
  }
  
  #region "nested classes"
  public class UNB
  {
      public string unb { get; set; }
      public string unb_2 { get; set; }
  }
  
  public class UNH
  {
      public string unh { get; set; }
      public string unh_2 { get; set; }
  }
  
  public class UVT
  {
      public string uvt { get; set; }
      public string uvt_1 { get; set; }
      public string uvt_2 { get; set; }
  }
  
  public class VIN 
  {
      public string vin { get; set; }
      public string vin_1 { get; set; }
      public string vin_2 { get; set; }
      public string vin_3 { get; set; }
      public string vin_4 { get; set; }
  }
  #endregion
  </code></pre>
  
  <p>The attributes of the nested classes are all strings, because this simplifies the XML serialization for now (I'm still in the conception phase).</p>
  
  <p>In my corresponding ViewModel, I've simply created a property for the nested class inside the model, so I can access all of the nested properties with just referring to this nested class from the ViewModel.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class OPERViewModel : IViewModelBase
  {
      private OPER_FILE Model;
  
      public UNB unb 
      { 
          get
          { return Model.unb;}
          set
          { Model.unb = value; }
      }
  
      public OPER oper
      {
          get
          { return Model.oper; }    //this is the tricky part, by now I'm just referring to the nested class as a property of the model
          set
          { Model.oper = value; }
      }
  
      public OPERViewModel()
      { Model = new OPER_FILE(); }
  }
  </code></pre>
  
  <p>The question is, however, that I want to display some of the properties not as strings but as boolean values using checkboxes on the UI.</p>
  
  <p>Saying I want to display <code>Model.oper.vin.vin_1</code> as boolean (where the ViewModel should manage the conversion from <code>string</code> to <code>bool</code> in the getter of its own property reflection of <code>Model.oper.vin.vin_1</code>), how would I do that?</p>
  
  <p>Would I <em>really</em> have to implement every nested property from a nested class as an own property of the ViewModel (like stated below) to gain control over the way it will be returned to the UI?</p>
  
  <pre class="lang-cs prettyprint-override"><code>//ViewModel-implementation with type-conversion of a property from a nested class of the model
  //this would get bind to the UI instead of Model.oper.vin.vin_1
  public bool vin_1    
  {
      get
      {
          if (Model.oper.vin.vin_1 == "1")
          { return true; }
          else
          { return false; }
      }
      set
      {
          if (value)
          { Model.oper.vin.vin_1 = "1"; }
          else
          { Model.oper.vin.vin_1 = "0"; }
      }
  }
  </code></pre>
  
  <p>I hope there is a better solution out there...</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>What I forgot to mention before, there're not only <code>string</code>s that have to be displayed as <code>boolean</code>s, also <code>DateTime</code>-values that should be displayed as a <code>DatePicker</code>-control, integer-values that I would like to have as <code>NumberPicker</code>s and so on. </p>
  
  <p>The xml-file, on the other hand, will be consumed by an interface with some pretty fixed regulations that i need to match, such a dynamically leading zeros on both <code>integer</code>- and <code>float</code>-values, special date formats and commas instead of dots as decimal separators. So sticking with the <code>string</code>-values inside the object to serialize is a good way of maintaining control over how the values would get actually parsed inside the xml-file.</p>
  
  <p>I'll try and experiment with some different converters, as @BrandlyDOTNet reommended, but are still curious about how this could be solved in another way.</p>