title: Commanding not working for checkbox
body: <p>I've used Prism commanding for a lot of controls but can't get it to work on the checkbox. But its not working for the checkbox. I do notice that when I place break points on my property declarations they are being hit so some piece of it is wrong. Here's my code:</p>
  
  <pre><code>public class CheckBoxCommandBehavior : CommandBehaviorBase&lt;CheckBox&gt;
  {
      public CheckBoxCommandBehavior(CheckBox checkableObj)
          : base(checkableObj)
      {
          checkableObj.Checked += new RoutedEventHandler(checkableObj_Checked);
          checkableObj.Unchecked +=new RoutedEventHandler(checkableObj_Checked);
      }
  
      private void checkableObj_Checked(object s, RoutedEventArgs e)
      {
          ExecuteCommand();
      }
  }
  
  public static class CheckBoxChecked
  {
      private static readonly DependencyProperty CheckBoxCommandBehaviorProperty = DependencyProperty.RegisterAttached(
          "CheckBoxCommandBehavior",
          typeof(CheckBoxCommandBehavior),
          typeof(CheckBoxChecked),
          null);
  
      public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached(
          "Command",
          typeof(ICommand),
          typeof(CheckBoxChecked),
          new PropertyMetadata(OnSetCommandCallback));
  
      public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.RegisterAttached(
          "CommandParameter",
          typeof(object),
          typeof(CheckBoxChecked),
          new PropertyMetadata(OnSetCommandParameterCallback));
  
  
      public static void SetCommand(CheckBox toggleBtn, ICommand cmd)
      {
          toggleBtn.SetValue(CommandProperty, cmd);
      }
  
      public static ICommand GetCommand(CheckBox toggleBtn)
      {
          return toggleBtn.GetValue(CommandProperty) as ICommand;
      }
  
      public static void SetCommandParameter(CheckBox selector, object parameter)
      {
          selector.SetValue(CommandParameterProperty, parameter);
      }
  
      public static object GetCommandParameter(CheckBox selector)
      {
          return selector.GetValue(CommandParameterProperty);
      }
  
      public static CheckBoxCommandBehavior GetOrCreateBehavior(CheckBox toggleBtn)
      {
          var behavior = toggleBtn.GetValue(CheckBoxCommandBehaviorProperty) as CheckBoxCommandBehavior;
  
          if (behavior == null)
          {
              behavior = new CheckBoxCommandBehavior(toggleBtn);
              toggleBtn.SetValue(CheckBoxCommandBehaviorProperty, behavior);
          }
  
          return behavior;
      }
  
      public static void OnSetCommandCallback(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
      {
          var toggleBtn = depObj as CheckBox;
          if (toggleBtn != null)
          {
              CheckBoxCommandBehavior behavior = GetOrCreateBehavior(toggleBtn);
              behavior.Command = e.NewValue as ICommand;
          }
      }
  
      private static void OnSetCommandParameterCallback(DependencyObject depObject, DependencyPropertyChangedEventArgs e)
      {
          var toggleBtn = depObject as CheckBox;
          if (toggleBtn != null)
          {
              CheckBoxCommandBehavior behavior = GetOrCreateBehavior(toggleBtn);
              behavior.CommandParameter = e.NewValue;
          }
      }
  }
  </code></pre>
  
  <p>I'm also creating several checkboxes from a datatemplate inside of a listbox</p>
  
  <pre><code>&lt;ListBox x:Name="usersRoleAssociationsListBox" ItemsSource="{Binding UsersInRolesCollection}"
                                                   Height="180" 
                                                   Width="220"
                                                   Margin="5,5,5,5"&gt;
                                          &lt;ListBox.ItemTemplate&gt;
                                              &lt;DataTemplate&gt;
                                                  &lt;StackPanel Orientation="Horizontal"&gt;
                                                      &lt;CheckBox
                                                          IsChecked="{Binding IsAssociated}"
                                                          cmd:CheckBoxChecked.Command="{Binding ClickToAssociateUserCommand}"
                                                          cmd:CheckBoxChecked.CommandParameter="{Binding Path=SelectedItem, ElementName=usersRoleAssociationsListBox}"&gt;
                                                      &lt;/CheckBox&gt;
                                                      &lt;TextBlock Text="{Binding UserName}"&gt;&lt;/TextBlock&gt;
                                                  &lt;/StackPanel&gt;
                                              &lt;/DataTemplate&gt;
                                          &lt;/ListBox.ItemTemplate&gt;
                                      &lt;/ListBox&gt;
  </code></pre>