title: Bool to Visibility Converter in WPF
body: <p>I have three radio buttons and three group boxes and based on the selection of the radio button, group box should have been visible or collapsed, but nothing seems to work here. The code for my constructor gets executed, but still it seems things are overlapping each other.
  
      
          
      </p>
  
  <pre><code>&lt;baseControls:MaintainTemplate Style="{StaticResource {x:Type baseControls:MaintainTemplate}}" TitleText="{Binding TitleText}"&gt;
  
      &lt;baseControls:MaintainTemplate.TabSection&gt;
          &lt;Grid&gt;
              &lt;GroupBox&gt;
                  &lt;GroupBox.Header&gt;
                      &lt;TextBlock Text="Case Information" Style="{StaticResource TextBlockWhite}"/&gt;
                  &lt;/GroupBox.Header&gt;
                  &lt;GroupBox.Content&gt;
                      &lt;Grid x:Name="GridMain"&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource MaxHeightRowDefinition}"/&gt;
                              &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                              &lt;ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/&gt;
                              &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid Grid.Column="1" x:Name="GridSelectCustomer"&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                                  &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                                  &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                                  &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                  &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;TextBlock Grid.Row="1" Text="Select Customer" Style="{StaticResource TextBlockWhite}"/&gt;
                              &lt;ComboBox Grid.Row="1" Grid.Column="2" Width="150"  ItemsSource="{Binding Customers}" 
                            DisplayMemberPath="FirstName" SelectedValue="{Binding SelectedCustomer}"/&gt;
                              &lt;Button Grid.Row="1"  Grid.Column="4" Content="Quick Search"/&gt;
                              &lt;Button Grid.Row="1" Grid.Column="6" Content="Add New Customer"/&gt;
  
                              &lt;TextBlock Grid.Row="3" Text="Reference No" Style="{StaticResource TextBlockWhite}"/&gt;
                              &lt;TextBox Grid.Row="3"  Grid.Column="2"/&gt;
                              &lt;TextBlock Grid.Row="3"  Text="Case No" Grid.Column="4" Style="{StaticResource TextBlockWhite}"/&gt;
                              &lt;TextBox Grid.Row="3"  Grid.Column="6" Style="{StaticResource TextBoxReadOnly}"/&gt;
                          &lt;/Grid&gt;
                          &lt;GroupBox Grid.Row="2" Grid.Column="1" x:Name="GroupBoxCustomerInfo"&gt;
                              &lt;GroupBox.Header&gt;
                                  &lt;TextBlock Text="Customer Details" Style="{StaticResource TextBlockWhite}"&gt;&lt;/TextBlock&gt;
                              &lt;/GroupBox.Header&gt;
                              &lt;GroupBox.Content&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                                          &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                                          &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                                          &lt;RowDefinition Style="{StaticResource MinHeightRowDefinition}"/&gt;
                                          &lt;RowDefinition Style="{StaticResource AutoHeightRowDefinition}"/&gt;
                                      &lt;/Grid.RowDefinitions&gt;
                                      &lt;TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="0" Grid.Column="1" Text="Name"/&gt;
                                      &lt;TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="3"&gt;&lt;/TextBox&gt;
                                      &lt;TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="0" Grid.Column="5" Text="Phone No"/&gt;
                                      &lt;TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="7"&gt;&lt;/TextBox&gt;
                                      &lt;TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="2" Grid.Column="1" Text="Father's Name"/&gt;
                                      &lt;TextBox Style="{StaticResource TextBoxReadOnly}"  Grid.Column="3" Grid.Row="2"&gt;&lt;/TextBox&gt;
                                      &lt;TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="4" Grid.Column="1"  Text="Address"/&gt;
                                      &lt;TextBox Style="{StaticResource TextBoxMultiLineReadOnly}" Grid.Row="4" Grid.Column="3"  &gt;&lt;/TextBox&gt;
                                      &lt;TextBlock Style="{StaticResource TextBlockWhite}" Grid.Row="2" Grid.Column="5"  Text="Date Of Birth"/&gt;
                                      &lt;TextBox Style="{StaticResource TextBoxReadOnly}" Grid.Column="7" Grid.Row="2"&gt;&lt;/TextBox&gt;
  
                                  &lt;/Grid&gt;
                              &lt;/GroupBox.Content&gt;
                          &lt;/GroupBox&gt;
                          &lt;GroupBox Grid.Row="4" Grid.Column="1" x:Name="GroupBoxCaseType"&gt;
                              &lt;GroupBox.Header&gt;
                                  &lt;TextBlock Text="Case Type" Style="{StaticResource TextBlockWhite}"/&gt;
                              &lt;/GroupBox.Header&gt;
                              &lt;GroupBox.Content&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MaxWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource AutoWidthColumnDefinition}"/&gt;
                                          &lt;ColumnDefinition Style="{StaticResource MinWidthColumnDefinition}"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;RadioButton Grid.Column="1" x:Name="rdbMonthlyInterest"  Content="Monthly Interest" 
                                       Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsMonthlyInterestChecked}"/&gt;
                                      &lt;RadioButton Grid.Column="3" x:Name="rdbDailyInstallment" Content="Daily Installment" 
                                       Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsDailyInstallmentChecked}"/&gt;
                                      &lt;RadioButton Grid.Column="5" x:Name="rdbMonthlyInstallment" Content="Monthly Installment" 
                                       Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsMonthlyInstallmentChecked}"/&gt;
                                  &lt;/Grid&gt;
                              &lt;/GroupBox.Content&gt;
                          &lt;/GroupBox&gt;
                          &lt;GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding Path=IsMonthlyInterestChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource  VisibilityConverter}}" &gt;
                              &lt;GroupBox.Header&gt;
                                  &lt;TextBlock Style="{StaticResource TextBlockWhite}"&gt;Monthly Interest&lt;/TextBlock&gt;
                              &lt;/GroupBox.Header&gt;
                          &lt;/GroupBox&gt;
                          &lt;GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding Path=IsDailyInstallmentChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource  VisibilityConverter}}" &gt;
                              &lt;GroupBox.Header&gt;
                                  &lt;TextBlock Style="{StaticResource TextBlockWhite}"&gt;Daily Installment&lt;/TextBlock&gt;
                              &lt;/GroupBox.Header&gt;
                          &lt;/GroupBox&gt;
                          &lt;GroupBox Grid.Row="6" Grid.Column="1" Visibility="{Binding  Path=InMonthlyInstallmentChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource  VisibilityConverter}}" &gt;
                              &lt;GroupBox.Header&gt;
                                  &lt;TextBlock Style="{StaticResource TextBlockWhite}"&gt;Monthly Installment&lt;/TextBlock&gt;
                              &lt;/GroupBox.Header&gt;
                          &lt;/GroupBox&gt;
                      &lt;/Grid&gt;
                  &lt;/GroupBox.Content&gt;
              &lt;/GroupBox&gt;
          &lt;/Grid&gt;
      &lt;/baseControls:MaintainTemplate.TabSection&gt;
  &lt;/baseControls:MaintainTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the code for the converter</p>
  
  <pre><code>    namespace Finance.MainUI.Common.Converters
      {
      public class BoolToVisibilityConverter : IValueConverter
      {
          public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
          {
              return (bool) value ? Visibility.Visible : Visibility.Collapsed;
          }
  
          public object ConvertBack(object value, Type targetType, object parameter,CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  }
  </code></pre>