title: Dynamically display a control depending on bound property using WPF
body: <p>I've got a property which is a database data type (<code>char</code>, <code>DateTime</code>, <code>int</code>, <code>float</code> etc...) and I want to change the control used to enter a value of the selected type. So for text values I want a <code>TextBox</code> and for date values I want a <code>DatePicker</code>.</p>
  
  <p>One way I thought about doing it was to have one of each control on my form and set their <code>Visibility</code> using an appropriate <code>IValueConverter</code> implementation. I know this will work, but it would create a lot of code and doesn't feel very nice.</p>
  
  <p>The other way I thought was to use a <code>ContentPresenter</code> and set its content with a <code>Style</code> and <code>DataTriggers</code> but I can't get it to work.</p>
  
  <pre><code>&lt;Style x:Key="TypedValueHelper" TargetType="{x:Type ContentPresenter}"&gt;
      &lt;Style.Triggers&gt;
          &lt;DataTrigger Binding="{Binding Path=DataType}" Value="Char"&gt;
              &lt;Setter Property="Content" Value="???"/&gt;
          &lt;/DataTrigger&gt;
          &lt;DataTrigger Binding="{Binding Path=DataType}" Value="Date"&gt;
              &lt;Setter Property="Content" Value="???"/&gt;
          &lt;/DataTrigger&gt;
          &lt;DataTrigger Binding="{Binding Path=DataType}" Value="Integer"&gt;
              &lt;Setter Property="Content" Value="???"/&gt;
          &lt;/DataTrigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>If anyone can fill in my <strong>"???"</strong> or offer a better solution please do. </p>