title: C# WPF accessing my view model from my model
body: <p>I'm new to MVVM and I'm trying to do a simple thing like writing a property in my class with a value from my view model.</p>
  
  <p>I've got a view model which contains a value <code>SettingsBarWidth</code> (this value can be written by my view). This value needs to read by my <code>Bar</code> class.</p>
  
  <p>How can I set my <code>Width</code> from my <code>Bar</code> class with the value in my ViewModel (<code>SettingsBarWidth</code>)?</p>
  
  <p>ViewModel:</p>
  
  <pre><code>    private int _SettingsBarWidth;
      public int SettingsBarWidth
      {
          get { return _SettingsBarWidth; }
          set
          {
              if (value != _SettingsBarWidth)
              {
                  SetProperty(ref _SettingsBarWidth, value);
              }
          }
      }
  </code></pre>
  
  <p>My class contains this:</p>
  
  <pre><code>public class Bar
  {
      public string ID { get; set; }
      public Point CenterPoint { get; set; }
      public double Length { get; set; }
      public double Width  { get; set; }          
      public double Angle { get; set; }
      public List&lt;Point&gt; Points { get; set; }
  }
  </code></pre>