title: RelayCommand not firing CanExecute
body: <p>I'm trying to create a command that binds to a button, and depends on a hierarchy of viewmodels to represent a pivot and pivotitems in a wp7 app. It goes something like this (i'll omit as much boilerplate code as possible):</p>
  
  <p>Parent viewmodel : </p>
  
  <pre class="lang-c# prettyprint-override"><code>    public RelayCommand RefreshCommand
      {
          get
          {
              return _refreshCommand;
          }
  
          set
          {
              if (_refreshCommand == value)
              {
                  return;
              }
  
              var oldValue = _refreshCommand;
              _refreshCommand = value;
  
              // Update bindings, no broadcast
              RaisePropertyChanged(RefreshCommandPropertyName);
          }
      }
  
  
      public RelayCommand&lt;RoutedEventArgs&gt; LoadedCommand
      {
          get
          {
              Action&lt;RoutedEventArgs&gt; getCurrentViewmodel = (args) =&gt;
              {
                  CurrentViewModel = SearchByLocationViewModel; // maybe something better...
                  RefreshCommand = CurrentViewModel.RefreshResultsCommand;
                  RefreshCommand.RaiseCanExecuteChanged();
              };
              return new RelayCommand&lt;RoutedEventArgs&gt;(getCurrentViewmodel);
          }
      }
  
      public RelayCommand&lt;SelectionChangedEventArgs&gt; PivotItemChangedCommand
      {
          get
          {
              Action&lt;SelectionChangedEventArgs&gt; pivotChanged = (args) =&gt;
              {
                  if (args != null)
                  {
                      // update current viewmodel
                      CurrentViewModel = ((Microsoft.Phone.Controls.PivotItem) args.AddedItems[0]).DataContext as ISearchViewModelBase;
                      RefreshCommand = CurrentViewModel.RefreshResultsCommand;
                  }
              };
              return new RelayCommand&lt;SelectionChangedEventArgs&gt;(pivotChanged);
          }
      }
  </code></pre>
  
  <p>So, i'm setting the parent view model's RefreshCommand property to the child command each time it loads, and I do the same when the selected pivotitem changes.</p>
  
  <p>Xaml</p>
  
  <pre><code>&lt;Button Command="{Binding RefreshCommand}" /&gt;
  </code></pre>
  
  <p>Child viewmodel</p>
  
  <pre class="lang-c# prettyprint-override"><code>public Func&lt;bool&gt; CanRefresh
  {
      get { return () =&gt; !IsLoading; }
  }
  
  private RelayCommand refreshResultsCommand;
  
  public RelayCommand RefreshResultsCommand
  {
      get
      {
          Action doRefresh = () =&gt;
          {
              SearchResults.Clear();
              this._pageNumber = 0;
              AddItems();
          };
          return refreshResultsCommand = refreshResultsCommand ?? new RelayCommand(doRefresh, CanRefresh);
      }
  }
  </code></pre>
  
  <p>What happens is, the CanRefresh is NEVER called. The commands work fine, depending on the pivotitem it calls one AddItems (that's a virtual method implemented differently in each child viewmodel) or the other, but it's like CanExecute is never raised. I'm using MVVM Light toolkit.
  Thanks!</p>