title: ICommand in MVVM WPF
body: <p>I'm having  a look at this MVVM stuff and I'm facing a problem.</p>
  
  <p>The situation is pretty simple.</p>
  
  <p>I have the following code in my index.xaml page</p>
  
  <pre><code>    &lt;Grid&gt;
      &lt;ItemsControl ItemsSource="{Binding}"&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;view:MovieView &gt;&lt;/view:MovieView&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>and in my index.xaml.cs</p>
  
  <p>...</p>
  
  <p>InitializeComponent();
  base.DataContext = new MovieViewModel(ent.Movies.ToList());
  ....</p>
  
  <p>and here is my MoveViewModel </p>
  
  <pre><code>    public class MovieViewModel
  {
      readonly List&lt;Movies&gt; _m;
      public ICommand TestCommand { get; set; }
      public MovieViewModel(List&lt;Movies&gt; m)
      {
          this.TestCommand = new TestCommand(this);
          _m = m;
      }
      public List&lt;Movies&gt; lm
      {
          get
          {
              return _m;
          }
      }
  }
  </code></pre>
  
  <p>finally</p>
  
  <p>here is my control xaml MovieView</p>
  
  <pre><code>    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto" /&gt;
          &lt;RowDefinition Height="Auto" /&gt;
          &lt;RowDefinition Height="Auto" /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
          &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Label VerticalAlignment="Center" Grid.Row="0" Grid.Column="0"&gt;Title :&lt;/Label&gt;&lt;TextBlock VerticalAlignment="Center" Grid.Row="0" Grid.Column="1" Text="{Binding Title}"&gt;&lt;/TextBlock&gt;  
      &lt;Label VerticalAlignment="Center" Grid.Row="1" Grid.Column="0"&gt;Director :&lt;/Label&gt;&lt;TextBlock VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Text="{Binding Director}"&gt;&lt;/TextBlock&gt;
      &lt;Button Grid.Row="2" Height="20" Command="{Binding Path=TestCommand}" Content="Edit" Margin="0,4,5,4" VerticalAlignment="Stretch" FontSize="10"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>So the problem I have is that if I set ItemsSource at Binding</p>
  
  <p></p>
  
  <p>it doesn't make anything</p>
  
  <p>if I set ItemsSource="{Binding lm}"</p>
  
  <p>it populates my itemsControl but the Command (Command="{Binding Path=TestCommand}" ) doesn't not work.</p>
  
  <p>Of course it doesn't not work because TestCommand doesn't not belong to my entity object Movies.</p>
  
  <p>So finally my question is,</p>
  
  <p>what do I need to pass to the ItemsControl to make it working?</p>
  
  <p>Thx in advance</p>