title: Pass Data to Data Template Selector
body: <p>How do you guys pass the data (parameter) to DataTemplate Selector? </p>
  
  <p>The only one that I can think of is to use an attached property in DataTemplate Selector? </p>
  
  <p>Example: </p>
  
  <pre><code>public class DisableWeekendsSelection : DataTemplateSelector
      {
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2211:NonConstantFieldsShouldNotBeVisible", Justification = "DependencyProperty")]
          public static readonly DependencyProperty Parameter =
             DependencyProperty.RegisterAttached("Parameter", typeof(ObservableCollection&lt;Date&gt;), typeof(DisableWeekendsSelection),
             new FrameworkPropertyMetadata(null,
                 FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
  
          public static ObservableCollection&lt;Date&gt; GetParameter(DependencyObject dp)
          {
              return dp.GetValue(Parameter) as ObservableCollection&lt;Date&gt;;            
          }
  
          public static void SetParameter(DependencyObject dp, ObservableCollection&lt;Date&gt; value)
          {            
              dp.SetValue(Parameter, value);
          }
  
          public override DataTemplate SelectTemplate(object item, DependencyObject container)
          {
  </code></pre>
  
  <p>The problem with this approach is that I'm not able to get the value of Parameter in SelectTemplate method. </p>
  
  <p>Any suggestion would be appreciated. Thanks in advance. </p>