title: Return null in boolean to checkbox state converter in XAML
body: <p>I have a TaskStatus to Boolean converter that implements the IValueConverter interface in XAML for Windows Store Apps (universal apps).</p>
  
  <p>I have three task states and I enabled the indeterminate state in a checkbox using IsThreeState="true".</p>
  
  <p>Now although the IsChecked property seems to be a Boolean?, the converter always gets System.Boolean as target type. Whatever I return (null for example) always converts to false and therefore I can't get the third state in my checkbox.</p>
  
  <p>Is there a way to either specify the TargetType in my converter or return a null so that IsChecked gets null as input and therefore shows the third state?</p>
  
  <p>Here is the converter:</p>
  
  <pre><code>public class TaskStatusToCheckBoxStateConverter : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, string language)
      {
          var taskStatus = (TaskStatus) value;
          switch (taskStatus)
          {
              case TaskStatus.Open:
                  return false;
              case TaskStatus.InProgress:
                  return null;
              case TaskStatus.Done:
                  return true;
              default:
                  throw new ArgumentOutOfRangeException();
          }
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, string language)
      {
          var checkBoxState = (Boolean?) value;
          if (checkBoxState == null)
              return TaskStatus.InProgress;
          if (checkBoxState.Value)
              return TaskStatus.Done;
          return TaskStatus.Open;
      }
  }
  </code></pre>
  
  <p>XAML-Code for the Checkbox</p>
  
  <pre><code>&lt;CheckBox x:Name="CheckBoxTaskState" 
      IsThreeState="True"
      IsChecked="{Binding Status, 
                  Converter={StaticResource TaskStatusToCheckBoxStateConverter}, 
                  Mode=TwoWay}"&gt;
  &lt;/CheckBox&gt;
  </code></pre>