title: NavigationService WithParam of Caliburn Micro for WP
body: <p>As is well known, CM doesn't support passing a object of complex type through NavigationService like MVVM Light. So I searched for a workaround and did it like this.</p>
  
  <p>There are two viewmodels: MainPageViewModel and SubPageViewModel.</p>
  
  <p>I first defined 3 classes, namely GlobalData, SnapshotCache and StockSnapshot. StockSnapshot is the type of which the object I want to pass between the 2 viewmodels.</p>
  
  <pre><code>public class SnapshotCache : Dictionary&lt;string, StockSnapshot&gt;
  {
      public StockSnapshot GetFromCache(string key)
      {
          if (ContainsKey(key))
              return this[key];
  
          return null;
      }
  }
  
  public class GlobalData
  {
      private GlobalData()
      {
  
      }
  
      private static GlobalData _current;
      public static GlobalData Current
      {
          get
          {
              if (_current == null)
                  _current = new GlobalData();
  
              return _current;
          }
          set { _current = value; }
      }
  
      private SnapshotCache _cachedStops;
      public SnapshotCache Snapshots
      {
          get
          {
              if (_cachedStops == null)
                  _cachedStops = new SnapshotCache();
  
              return _cachedStops;
          }
      }
  }
  
  public class StockSnapshot
  {
      public string Symbol { get; set; }
      public string Message { get; set; }
  }
  </code></pre>
  
  <p>Next, I call the navigation service on MainPageViewModel like this:</p>
  
  <pre><code>StockSnapshot snap = new StockSnapshot {Symbol="1", Message = "The SampleText is here again!" };
  GlobalData.Current.Snapshots[snap.Symbol] = snap;
  NavigationService.UriFor&lt;SubPageViewModel&gt;().WithParam(p=&gt;p.Symbol,snap.Symbol).Navigate();
  </code></pre>
  
  <p>And on SubPageViewModel I've got this:</p>
  
  <pre><code>    private string _symbol;
      public string Symbol
      {
          get { return _symbol; }
          set
          {
              _symbol = value;
              NotifyOfPropertyChange(() =&gt; Symbol);
          }
      }
  
      public StockSnapshot Snapshot
      {
          get { return GlobalData.Current.Snapshots[Symbol]; }
      }
  </code></pre>
  
  <p>And that's where the problem lies. When I run the program, I find out that it always runs to the getter of Snapshot first, when Symbol hasn't been initialized yet. So later I've tried adding some extra code to eliminate the ArgumentNullException so that it can run to the setter of Symbol and then everything goes fine except that the UI doesn't get updated anyway.</p>
  
  <p>Could anyone tell me where I've got wrong?
  Thx in advance!!</p>