title: MvvmLight in a class that uses composition
body: <p>I have a ViewModel, derived from <code>MvvmLight.ViewModelBase</code> that uses composition to reuse other classes:</p>
  
  <p>Simplified version of the classes that I want to reuse in a composition:</p>
  
  <pre><code>class TimeFrameFactory
  {
      public DateTime SelectedTime {get; set;}
  
      public ITimeFrame CreateTimeFrame() {...}
  }
  
  class GraphFactory
  {
       public int GraphWidth {get; set;}
  
       public IGraph CreateGraph(ITimeframe timeframe) {...}
  }
  </code></pre>
  
  <p>My ViewModel, derived from MvvmLight ViewModelBase is a composition of these two:</p>
  
  <pre><code>class MyViewModel : ViewModelBase
  {
      private readonly TimeFrameFactory timeFrameFactory = new TimeFrameFactory();
      private readonly GraphFactory graphFactory = new GraphFactory();
  
      private Graph graph;
  
      // standard MVVM light method to get/set a field:
      public Graph Graph
      {
          get =&gt; this.Graph;
          private set =&gt; base.Set(nameof(Graph), ref graph, value);
      }
  
      // this one doesn't compile:
      public DateTime SelectedTime 
      {
          get =&gt; this.timeFrameFactory.SelectedTime;
          set =&gt; base.Set(nameof(SelectedTime), ref timeFrameFactory.SelectedTime, value);
      }
  
      // this one doesn't compile:
      public int GraphWidth
      {
          get =&gt; this.timeFrameFactory.GraphWidth;
          set =&gt; base.Set(nameof(GraphWidth), ref timeFrameFactory.GraphWidth, value);
      }
  
      public void CreateGraph()
      {
          ITimeFrame timeFrame = this.timeFrameFactory.CreateTimeFrame();
          this.Graph = this.GraphFactory.CreateGraph(timeFrame);
      }
  }
  </code></pre>
  
  <p>Get/Set with a field works, but if I want to forward setting a property to the composite object, I can't use <code>base.Set</code></p>
  
  <pre><code>set =&gt; base.Set(nameof(GraphWidth), ref timeFrameFactory.GraphWidth, value);
  </code></pre>
  
  <p>ref is not allowed on properties.</p>
  
  <p>Of course I could write:</p>
  
  <pre><code>    public int GraphWidth
      {
          get =&gt; this.timeFrameFactory.GraphWidth;
          set
          {
              base.RaisePropertyChanging(nameof(GraphWidh));
              base.Set(nameof(GraphWidth), ref timeFrameFactory.GraphWidth, value);
              base.RaisePropertyChanged(nameof(GraphWidh));
          }
      }
  </code></pre>
  
  <p>Quite a nuisance if you have to do this for a lot of properties. Is there a neat way to do this, possibly similar to <code>ObservableObject.Set</code>?</p>