title: MVVM Light Commands within an ItemsControl
body: <p>I'm just trying my hand at WP7 dev using the MVVM Light framework.</p>
  
  <p>I'm trying to fire a button command inside an ItemsControl, essentialy it's a list of cars and I'd like each element to have an edit button.
  The Relevant piece of the View:</p>
  
  <pre><code>&lt;ItemsControl ItemsSource="{Binding MyCars}" &gt;
  &lt;ItemsControl.ItemTemplate&gt;
      &lt;DataTemplate&gt;
          &lt;Grid x:Name="CarViewGrid"&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="Auto" MinWidth="100" /&gt;
                  &lt;ColumnDefinition Width="Auto" MinWidth="302"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="40" /&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="32" /&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="32" /&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="32" /&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;TextBlock x:Name="CarName" Text="{Binding Name, Mode=TwoWay}" Margin="7,0" Grid.Row="0" Grid.ColumnSpan="2" FontSize="32" FontWeight="Bold" FontStyle="Normal" /&gt;
              &lt;TextBlock x:Name="Make" Text="{Binding Make, Mode=TwoWay}" Margin="15,0" Grid.Row="1" Grid.Column="0" FontSize="24" /&gt;
              &lt;TextBlock x:Name="Model" Text="{Binding Model, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" FontSize="24" /&gt;
              &lt;TextBlock x:Name="Odometer" Text="{Binding Odometer, Mode=TwoWay}" Margin="15,0"  Grid.Row="2" Grid.ColumnSpan="2" FontSize="24" /&gt;
              &lt;Button x:Name="EditCarButton" Content="Edit" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" Width="100" &gt;
                  &lt;i:Interaction.Triggers&gt;
                      &lt;i:EventTrigger EventName="Click"&gt;
                          &lt;cmd:EventToCommand Command="{Binding EditCar}" CommandParameter="{Binding}"/&gt;
                      &lt;/i:EventTrigger&gt;
                  &lt;/i:Interaction.Triggers&gt;
              &lt;/Button&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  &lt;/ItemsControl.ItemTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>My ViewModel contains this:</p>
  
  <pre><code>    public RelayCommand OpenNewForm { get; private set; }
  
      public CarViewModel()
      {
          //Snip
          EditCar = new RelayCommand&lt;Car&gt;(c =&gt;
          {
              CurrentCar = c;
              FormVisible = true;
          });
      }
  </code></pre>
  
  <p>Now as you can see I'm trying to pass the current Car object that is bound through the CommandParameter. My delegate never fires so I'm guessing I've got something wrong in my binding regarding the current DataContext.</p>
  
  <p>Anybody got any ideas as to what I'm doing wrong?</p>