title: C# - Passing View to the converter as parameter
body: <p>I have a <strong>view</strong> with couple of <strong>data templates</strong> in the <strong>resources</strong> of that view. <em>(I don't want to put it somewhere global since its only needed by this particular view)</em></p>
  
  <p>Based on value I get in converter I switch the template. </p>
  
  <pre><code>public class SplitTemplateSelector : IValueConverter
      {
  
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              int splitCount = (int)value;
              var _view = new IdtDetailView();
  
              DataTemplate template;
              if (splitCount == 1)
              {
                  //(DataTemplate)_view.Resources["SingleSplitTemplate"];
                  template = (DataTemplate)_view.Resources.Where(w =&gt; w.Key.Equals("SingleSplitTemplate")).FirstOrDefault().Value;
              }
              else
              {
                  template = (DataTemplate)_view.Resources.Where(w =&gt; w.Key.Equals("MultiSplitTemplate")).FirstOrDefault().Value;
              }
  
              return template;
          }
  
          public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
          {
              throw new NotSupportedException();
          }
      }
  </code></pre>
  
  <p>This works as intended, however because I instantiate new <code>IdtDetailView()</code>, I run into some problems where variables aren't set-up properly etc. Therefore my question is... </p>
  
  <p><strong>How do I pass or access view which called this converter so that I don't have to create new IdtDetailView?</strong></p>