title: Data binding a button visibility in WPF isn't working
body: <p>Alot of code incoming, Some of this might be useless because i was trying alot of things to get this working.  </p>
  
  <p>I am trying to make the button Export Installer invisible unless the selected installer has a value of TRUE on IsDownloaded</p>
  
  <p>so i'll start with my WPF</p>
  
  <pre><code>        DataContext="{Binding Source={StaticResource TheViewModel}}"
      Title="MainWindow" Height="458" Width="755"&gt;
  &lt;Window.Resources&gt;
      &lt;ViewModel:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /&gt;
      &lt;ViewModel:InstallerColorConverter x:Key="InstallerColorConverter" /&gt;
  &lt;/Window.Resources&gt;
  
  &lt;ListBox Height="300" Grid.Column="0" Grid.Row="0" SelectionMode="Single" ItemsSource="{Binding SelectedProduct.Installers}" SelectedItem="{Binding SelectedInstaller}" &gt;
                          &lt;ListBox.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                      &lt;Ellipse HorizontalAlignment="Right" Fill="{Binding InstallerRelativeToCurrent, Converter={StaticResource InstallerColorConverter}}" Margin="5,5,5,5 " Height="20" Width="20" Stroke="Black"&gt;&lt;/Ellipse&gt;
                                      &lt;TextBlock Margin="5,0,5,0" Text="{Binding Name}" /&gt;
                                      &lt;TextBlock  Text=" " /&gt;
                                      &lt;TextBlock Text="{Binding VersionNumber}" /&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ListBox.ItemTemplate&gt;
                      &lt;/ListBox&gt;
                      &lt;StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Stretch"&gt;
                          &lt;Button Name="btnInstall"  Margin="5,5,5,5" Height="50" Width="75" MouseDoubleClick="btnDownloadInstaller_MouseDoubleClick" &gt;Download&lt;/Button&gt;
                          &lt;Button Name="btnExportInstaller" Visibility="{Binding Path=SelectedInstaller.IsDownloaded, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}}, Converter={StaticResource BoolToVisibilityConverter}}" Margin="5,5,5,5" Height="50" Width="90" MouseDoubleClick="btnExportInstaller_MouseDoubleClick" &gt;Export Installer&lt;/Button&gt;
                      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>The main things to point out in that is </p>
  
  <pre><code>             &lt;Button Name="btnExportInstaller" Visibility="{Binding Path=SelectedInstaller.IsDownloaded, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Button}}, Converter={StaticResource BoolToVisibilityConverter}}" Margin="5,5,5,5" Height="50" Width="90" MouseDoubleClick="btnExportInstaller_MouseDoubleClick" &gt;Export Installer&lt;/Button&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>        &lt;ViewModel:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /&gt;
  </code></pre>
  
  <p>now in my class BoolToVisibilityConver </p>
  
  <pre><code>    public class BoolToVisibilityConverter : IValueConverter
  {
      public object Convert(object value, Type targetType,
      object parameter, CultureInfo culture)
      {
          var booool = (bool)value;
          if (booool)
              return Visibility.Collapsed;
          else
              return Visibility.Visible;
  
      }
  
      public object ConvertBack(object value, Type targetType,
          object parameter, CultureInfo culture)
      {
          // Do the conversion from visibility to bool
          return Visibility.Collapsed;
      }
  }
  </code></pre>
  
  <p>Then finally in the view model i have </p>
  
  <pre><code>        private Visibility _IsVisible;
      public Visibility IsVisible
      {
          get { return _IsVisible; }
          set { _IsVisible = value; OnPropertyChanged(nameof(_SelectedInstaller.IsDownloaded)); } 
      }
  
     private Products _SelectedProduct;
      public Products SelectedProduct
      {
          get { return _SelectedProduct; }
          set { _SelectedProduct = value; OnPropertyChanged(nameof(SelectedProduct)); }
  
    private Installers _SelectedInstaller;
          public Installers SelectedInstaller
          {
              get { return _SelectedInstaller; }
              set { _SelectedInstaller = value; OnPropertyChanged(nameof(SelectedInstaller)); }
  </code></pre>
  
  <p>It doesn't work</p>
  
  <p>I'm getting these 2 errors on the console and i don't understand them</p>
  
  <pre><code>System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'System.Boolean' and 'System.Windows.Visibility'. Consider using Converter property of Binding. BindingExpression:Path=SelectedProduct.IsInstalled; DataItem='ViewModel' (HashCode=26987408); target element is 'Grid' (Name=''); target property is 'Visibility' (type 'Visibility')
  System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='False' BindingExpression:Path=SelectedProduct.IsInstalled; DataItem='ViewModel' (HashCode=26987408); target element is 'Grid' (Name=''); target property is 'Visibility' (type 'Visibility')
  </code></pre>
  
  <p>If anyone can point out what i'm doing wrong here i would love you forever! </p>