title: Silverlight 3/Prism - Passing an enum value as a Command Parameter
body: <p>I'm trying to use Prism and the MVVM pattern to develop an application.  In my UI, I have a previous and next button defined.  For use in a calling  web services, I've defined an enum that will tell me the direction I need to traverse.  So, in this instance, the buttons map directly to an enum value.  The enum definition is very simple and is as follows:</p>
  
  <pre><code>namespace CodeExpert.Book.Helpers
  {
      public enum BookDirection { Previous = -1, NotSet = 0, Next = 1, }
  }
  </code></pre>
  
  <p>I've defined my command and delegate in my ViewModel and assigned the propery correctly.  The relevant code is:</p>
  
  <pre><code>public DelegateCommand PreviousNextCommand { get; set; }
  
  public IndexEntriesViewModel(GlobalVariables globalVariable, IndexEntryOperations currentOperator)
  {
      //a bunch of initialization code.
      InitializeCommands();
  }
  
  void InitializeCommands()
  {
      PreviousNextCommand =
          new DelegateCommand(OnPreviousNextCommandExecute);
  }
  
  private void OnPreviousNextCommandExecute(BookDirection parameter)
  {
  
      //Code to process based on BookDirection
  }
  </code></pre>
  
  <p>So, based on this config, I want to pass a BookDirection enum value to the CommandParameter.  I can't, however, get the XAML right for this. Here's the XAML I've tried that seems the most correct to me:</p>
  
  <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   mc:Ignorable="d"
                   x:Class="CodeExpert.Book.Views.Index"
                   d:DesignWidth="1024"
                   d:DesignHeight="768"
                   xmlns:helpers="clr-namespace:CodeExpert.Book.Helpers"
                   xmlns:command="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
                   xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls"
                   xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                   xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
                   xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"&gt;
  
      &lt;Button x:Name="ButtonPrevious"
                HorizontalAlignment="Left"
                Margin="2,1,0,1"
                Width="25"
                Content="&lt;"
                Grid.Column="1"
                Grid.Row="1"
                Height="20"
                command:Click.Command="{Binding Path=CurrentIndexViewModel.PreviousNextCommand}"&gt;
          &lt;command:Click.CommandParameter&gt;
              &lt;helpers:BookDirection.Previous /&gt;
          &lt;/command:Click.CommandParameter&gt;
      &lt;/Button&gt;
  
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>I get no intellisense for the BookDirection for the enum and get an error at design &amp; compile time saying The type 'BookDirection' does not contain adefinition for 'Previous'.  Is there no way to pass that enum, or am I simply missing something?  I have it working now by setting the parameter type to <code>string</code> instead of <code>BookDirection</code>, but then I have to parse text and the code smells. I've done some Google searches and the closest thing I've come to an answer is here - <a href="https://stackoverflow.com/questions/359699/passing-an-enum-value-as-command-parameter-from-xaml">Passing an enum value as command parameter from XAML</a> Unfortunately, Silverlight doesn't support the x:static binding extension, so I can't use the exact technique described in that answer.</p>
  
  <p>Any help would be much appreciated.</p>