title: Enable,Disable button upon check/uncheck of checkboxes
body: <p>I have a view that contains a list box with various items in button form and a checkbox for each of the button. XAML:</p>
  
  <pre><code>        &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;Grid&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition /&gt;
                          &lt;ColumnDefinition /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;CheckBox x:Name="CheckFavorite"
                                Width="Auto"
                                Height="Auto"
                                AutomationProperties.AutomationId="AID_FavoritesCheck"
                                IsChecked="{Binding Path=IsChecked,
                                                    Mode=TwoWay}"
                                Visibility="{Binding IsFavoriteConfiguredAndInDA,
                                                     Converter={StaticResource boolToVisibility}}"
                                Checked="OnContentChanged"
                                Unchecked="OnContentChanged"/&gt;
                      &lt;Button Grid.Column="1"
                              Width="240"
                              HorizontalContentAlignment="Left"
                              VerticalContentAlignment="Center"
                              AutomationProperties.AutomationId="AID_BtnLaunchFavorite"
                              Command="{Binding Path=LaunchFavorite}"
                              Content="{Binding Path=ModuleDisplayName}"
                              Cursor="Hand"
                              FontSize="{StaticResource UxLevel_5}"
                              Padding="24 12 2 12"
                              ToolTip="{Binding Path=ModuleDisplayName}" /&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
  </code></pre>
  
  <p>I have another button called "Launch". Its basic functionality is to launch the tasks as per the selection in the above listbox items so that multiple tasks can be launched.Button XAML:</p>
  
  <pre><code>        &lt;Button Name="btnLaunch"
                  Width="80"
                  Height="25"
                  HorizontalAlignment="Left"
                  AutomationProperties.AutomationId="AUI_BtnLaunchForFavorite"
                  Command="{Binding LaunchCommand}"
                  Style="{StaticResource LaunchButtonStyle}"
                  Visibility="{Binding IsRIAMode,
                                       Converter={StaticResource boolToVisibilityInverter}}"&gt;
  </code></pre>
  
  <p>Issue:
  I want to enable/disable this launch button if atleast one item is selected and disable otherwise.How can i achieve? Pls help with some code snippets.</p>
  
  <p>UPDATE:
  Here is the launch command:</p>
  
  <pre><code>public ICommand LaunchCommand { get; private set; }
  LaunchCommand = new DelegateCommand&lt;object&gt;(OnLaunch);
          internal void OnLaunch(object sender)
          {
              var nFavItemToLaunchCount = Favorites.Count(favItem =&gt; favItem.IsChecked);
  
              if (!IsSessionLimitReached(nFavItemToLaunchCount))
              {
                  foreach (FavoriteItemViewModel favoriteItem in Favorites)
                  {
                      if (favoriteItem.IsChecked)
                      {
                          favoriteItem.LaunchFavorite.Execute(sender);
  
                      }
                  }
              }
          }
  </code></pre>
  
  <p>UPDATE 2:</p>
  
  <p>I made the changes as per Krishna's comment:</p>
  
  <pre><code> LaunchCommand = new DelegateCommand&lt;object&gt;(OnLaunch,ToggleLaunch);
   private bool ToggleLaunch(object obj)
   {
  
        if (Favorites.Count(i =&gt; i.IsChecked)!=0)  //Favorites is the itemsource
        {
                  return true;
        }
              return false;
   }
  </code></pre>
  
  <p>Still the launch button is shown disabled always even when item is selected/checked.</p>
  
  <p>UPDATE 3</p>
  
  <p>After Krishna's further comment, i changed the implementation of the property IsChecked and also implemented INotifyPropertyChanged in the viewmodel.Still no luck!</p>
  
  <pre><code>public class FavoriteItemViewModel:INotifyPropertyChanged
  {
          public bool IsChecked
          {
              get
              {
                  return m_IsChecked;
              }
              set
              {
                  m_IsChecked = value;
                  OnPropertyChanged("IsChecked");
              }
          }
  
          /// &lt;summary&gt;
          /// Handler for property change
          /// &lt;/summary&gt;
          /// &lt;param name="propertyName"&gt;Name of property&lt;/param&gt;
          protected void OnPropertyChanged(string propertyName)
          {
              PropertyChangedEventHandler handler = PropertyChanged;
  
              if (handler != null)
              {
                  handler(this, new PropertyChangedEventArgs(propertyName));
              }
          }
  }
  </code></pre>
  
  <p>There is another viewmodel "FavoriteContainerViewModel" that holds the collection of "FavoriteItemViewModel"  and also implements INotifyPropertyChanged. This container view model is the place where i added the code mentioned in UPDATE 2</p>
  
  <p>UPDATE 4:
  Implementation of favorites:</p>
  
  <pre><code>public class FavoriteContainerViewModel : ViewModelBase, IModuleView
  {
      private readonly ObservableCollection&lt;FavoriteItemViewModel&gt; m_Favorites = new ObservableCollection&lt;FavoriteItemViewModel&gt;();
  
          public ObservableCollection&lt;FavoriteItemViewModel&gt; Favorites
          {
              get { return m_Favorites; }
          }
          public FavoriteContainerViewModel()
          {
              LaunchCommand = new DelegateCommand&lt;object&gt;(OnLaunch, ToggleLaunch);
              OnLoad();
          }
          private bool ToggleLaunch(object obj)
          {
              if (Favorites.Count(i =&gt; i.IsChecked) != 0)
              {
                  return true;
              }
              return false;
              //return true;
          }
  }
  </code></pre>
  
  <p>Note:ViewModelBase implements INotifyPropertyChanged</p>
  
  <p>Update 5:
  Problem now resolved using event based model. Implemented following:
  FavoriteViewModel.cs</p>
  
  <pre><code>public event EventHandler ItemChecked;
  public bool IsChecked
  {
      get
      {
          return m_IsChecked;
      }
      set
      {
          m_IsChecked = value;
          if (ItemChecked != null)
          {
              ItemChecked(this, new EventArgs());
          }
      }
  }
  </code></pre>
  
  <p>FavoriteItemContainerViewModel.cs</p>
  
  <pre><code>private void SubscribeFavoriteItemEvents(FavoriteItemViewModel favorite)
  {
       favorite.ItemChecked += ToggleLaunchButton;
  }
  
  private bool m_IsLaunchEnabled;
  public bool IsLaunchEnabled
  {
      get
      {
          return m_IsLaunchEnabled;
      }
      set
      {
          m_IsLaunchEnabled = value;
          OnPropertyChanged("IsLaunchEnabled");
      }
  }
  </code></pre>
  
  <p>Property IsLaunchEnabled is binded to the button to enable/disable.</p>