title: Enabling a button in WPF depending on Multiple Conditions(switch case type)
body: <p>I have my xaml structure something like this:</p>
  
  <ol>
  <li>Radio buttons and corresponding controls that will be enabled if the radio button is selected. For Example, if the radio button food is selected, then two text boxes will be enabled, for the radio button Drinks, a combo box will be enabled.</li>
  <li>And a Button to process the the data in the dialog.</li>
  </ol>
  
  <p>I want to enable the Button only when one radio button is selected and its corresponding controls are populated. 
  I am using a command for the button in my view model. Please help me do this.</p>
  
  <h2>Command for the button</h2>
  
  <pre><code>    EnableProcessButton = new RelayCommand(ExecuteButton, CanExecuteButton);  
      public ICommand EnableProcessButton
      {
          get;
          internal set;
      }
      private bool CanExecuteButton(object obj)
      {
          switch (SelectedMode)
          {
              case "Drinks": return (!string.IsNullOrEmpty(SelectedDrink));
                  break;
              case "Food": return ((!string.IsNullOrEmpty(text1)) &amp;&amp; (text2 != default(int)));//The second text box is implemented as a numeric one
                  break;                
              default: return false;
                  break;
          }
  
      }
  
      private void ExecuteButton(object obj)
      {
          //DO the required things.
      }
  </code></pre>
  
  <p>Xaml</p>
  
  <pre><code>&lt;StackPanel&gt;
          &lt;TextBox x:Name="FoodBox1"  Width="120" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="{Binding ElementName=Food, Path=IsChecked}" UndoLimit="5"
                        Text="{Binding textbox1, UpdateSourceTrigger=PropertyChanged}" TextChanged="Foodbox1_TextChanged"/&gt;
  
          &lt;TextBox Name="FoodBox2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="120" Margin="10" IsEnabled="{Binding ElementName=Food, Path=IsChecked}" UndoLimit="5"
                  MaxLength="5" TextChanged="FoodBox2_TextChanged" Validation.ErrorTemplate="{x:Null}" Text="{Binding textbox2,  UpdateSourceTrigger=PropertyChanged}" /&gt;
  
   &lt;/StackPanel&gt;
      &lt;ComboBox Name="DrinkOptions" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Center"  VerticalAlignment="Center" Width="120" Margin="10" IsEnabled="{Binding ElementName=Drinks, Path=IsChecked}"
                    ItemsSource="{Binding AvailableDrinks}" SelectedValue="{Binding SelectedDrink}"/&gt;
  </code></pre>
  
  <p>When something is written into the textbox and then removed, the button isn't disabled.There is no problem with the combo box.</p>