title: Inject ViewModel with data throws Exception
body: <p>This I got: <strong>A first chance exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll</strong></p>
  
  <p>When I use a parameter for the constructor of my <em>LessonPlannerViewModel</em> class.</p>
  
  <p>I use a datatemplateselector class to switch between weekly/daily view.</p>
  
  <pre><code>public class ApplicationNavigationTemplateSelector : DataTemplateSelector
  {
      public override DataTemplate SelectTemplate(object item, DependencyObject container)
      {
          if (item is LessonPlannerViewModel)
          {
              var vm = item as LessonPlannerViewModel;
              Window window = Application.Current.MainWindow;                
  
              if (vm.IsDailyView)
                  return window.FindResource("dailyViewTemplate") as DataTemplate;
              else
                  return window.FindResource("weeklyViewTemplate") as DataTemplate;
          }
          return base.SelectTemplate(item, container);
      } 
  }
  
  public LessonPlannerViewModel(DateTime asOfDate)
      {
          _asOfDate = asOfDate;
  
          if(_isDailyView) 
              LoadDailyData();
          if(_isWeeklyView)
              LoadWeeklyData();
  </code></pre>
  
  <p>...</p>
  
  <p>Is that not allowed? Without the parameter I get no exception...</p>
  
  <p>What do I wrong?</p>
  
  <p>EDIT: NOw I changed the parameter to an integer and got better message ;P</p>
  
  <p><strong>XamlParseException=>
  'No matching constructor found on type 'TBM.ViewModel.LessonPlannerViewModel'. You can use the Arguments or FactoryMethod directives to construct this type.' Line number '13' and line position '10'.</strong></p>
  
  <p>ok this is now understandable, that</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ViewModel:LessonPlannerViewModel x:Key="LessonPlannerViewModelID" /&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>has no parameter.</p>
  
  <p>So what to do now?</p>