Prism: have to call RaiseCanExecuteChanged() explicitly
<p>Below is a very simple <code>Prism.Wpf</code> example with a <code>DelegateCommand</code> that has both <code>Execute</code> and <code>CanExecute</code> delegates.</p>

<p>Suppose that <code>CanExecute</code> depends on some property. It seems that Prism's <code>DelegateCommand</code> doesn't re-evaluate <code>CanExecute</code> condition automatically when this property changes, as <code>RelayCommand</code> does in other MVVM frameworks. Instead, you have to call RaiseCanExecuteChanged() explicitly in the property setter. This leads to a lot of repetitive code in any non-trivial viewmodel.</p>

<p>Is there a better way?</p>

<p><em>ViewModel</em>:</p>

<pre><code>using System;
using Prism.Commands;
using Prism.Mvvm;

namespace PrismCanExecute.ViewModels
{
public class MainWindowViewModel : BindableBase
{
    private string _title = "Prism Unity Application";
    public string Title
    {
        get { return _title; }
        set { SetProperty(ref _title, value); }
    }
    private string _name;
    public string Name
    {
        get { return _name; }
        set
        {
            SetProperty(ref _name, value);

            // Prism doesn't track CanExecute condition changes?
            // Have to call it explicitly to re-evaluate CanSubmit()
            // Is there a better way?
            SubmitCommand.RaiseCanExecuteChanged();
        }
    }
    public MainWindowViewModel()
    {
        SubmitCommand = new DelegateCommand(Submit, CanSubmit);
    }

    public DelegateCommand SubmitCommand { get; private set; }
    private bool CanSubmit()
    {
        return (!String.IsNullOrEmpty(Name));
    }
    private void Submit()
    {
        System.Windows.MessageBox.Show(Name);
    }

}
}
</code></pre>

<p><em>View</em>:</p>

<pre><code>&lt;Window x:Class="PrismCanExecute.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="http://prismlibrary.com/"
    Title="{Binding Title}"
    Width="525"
    Height="350"
    prism:ViewModelLocator.AutoWireViewModel="True"&gt;
&lt;Grid&gt;
    &lt;!--&lt;ContentControl prism:RegionManager.RegionName="ContentRegion" /&gt;--&gt;
    &lt;StackPanel&gt;
        &lt;StackPanel Orientation="Horizontal"&gt;
            &lt;TextBlock Text="Name: " /&gt;
            &lt;TextBox Width="150"
                     Margin="5"
                     Text="{Binding Name,  UpdateSourceTrigger=PropertyChanged}"/&gt;
        &lt;/StackPanel&gt;
        &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Center"&gt;
            &lt;Button Width="50"
                    Command="{Binding SubmitCommand}"
                    Content="Submit" Margin="10"/&gt;
            &lt;!--&lt;Button Width="50"
                    Content="Cancel"
                    IsCancel="True" Margin="10"/&gt;--&gt;
        &lt;/StackPanel&gt;
    &lt;/StackPanel&gt;
&lt;/Grid&gt;
&lt;/Window&gt;
</code></pre>