title: Prism Shell buttons shared by modules
body: <p>I am using Prism 2, trying to add four navigation buttons (First Record, Last Record, Previous Record, Next Record) in shell to be used by modules. I also want these buttons to be disable if active View/ViewModel does not provide these functions.</p>
  
  <p>I tried using events but didn't know how to achieve my second goal regarding disabling buttons. It seems I need to check current active View/ViewModel to see if they subscribed the click event during View switch. But I think publisher should be unaware of subscriber...</p>
  
  <p>Somehow I tried my own way. I create an IDocNavigation interface which has four method corresponding to my four buttons. At runtime I check modules' ViewModel if they implemented that interface or not, and change the ICommand on fly. Below is my code. I include one LastRecordCommand only:</p>
  
  <pre><code>public ShellViewModel(Views.Shell shell)
  {
  this.Shell = shell;
  shell.DataContext = this;
  
  shell.MainDocking.ActivePaneChanged += (s, e) =&gt;
  {
      if (e.NewPane.Content is UserControl &amp;&amp;
          ((UserControl)e.NewPane.Content).DataContext is IDocumentNavigate)
      {
  
          IDocumentNavigate vm = ((UserControl)e.NewPane.Content).DataContext as IDocumentNavigate;
          LastRecordCommand = new RelayCommand(x =&gt; vm.GotoLastRecord(), x =&gt; true);
      }
      else
      {
          LastRecordCommand = new RelayCommand(x =&gt; { }, x =&gt; false);
      }
  
  };
  //...
  </code></pre>
  
  <p>I feel these are quite ugly. Creating an empty RelayCommand is also stupid. How can I improve ? or how can I achieve disabling command if event is more suitable in my case ?</p>