title: Iterating selected items in Windows App Store Gridview
body: <p>I know this is a long one, but please bear with me.</p>
  
  <p>I have created a windows app store program very similar to Laurent Bugnion's "MyFriends" program in the MVVM light samples using the MVVM light framework. </p>
  
  <p>In his program he uses the SelectedItem property of the gridview to keep track of which item is the selected item.</p>
  
  <p>The problem is, I give the user the ability to select multiple items on the GridView and then operate on them using a button on the App Bar. For this SelectedItem will not work.</p>
  
  <p>Does anyone know how to make this work with a multiselect GridView? I have tried the IsSelected property of the GridViewItem based on some articles on WPF, but this doesn't seem to work. The SelectedTimesheets getter always come back empty when called. Here is what I have so far:</p>
  
  <p>MainPage.xaml (bound to a MainViewModel with a child TimesheetViewModel observable collection):</p>
  
  <pre><code>&lt;GridView 
      x:Name="itemGridView"
      IsItemClickEnabled="True"
      ItemsSource="{Binding Timesheets}"
      ItemTemplate="{StaticResource TimesheetTemplate}" 
      Margin="10"
      Grid.Column="0"
      SelectionMode="Multiple"
      helpers:ItemClickCommand.Command="{Binding NavigateTimesheetCommand}" RenderTransformOrigin="0.738,0.55"  &gt;
      &lt;GridView.ItemContainerStyle&gt;
          &lt;Style TargetType="GridViewItem"&gt;
              &lt;Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/&gt;
          &lt;/Style&gt;
      &lt;/GridView.ItemContainerStyle&gt;
  
  &lt;/GridView&gt;
  </code></pre>
  
  <p>MainViewModel (cut down from full code):</p>
  
  <pre><code>public class MainViewModel : ViewModelBase
  {
      private readonly IDataService _dataService;
      private readonly INavigationService _navigationService;
  
      /// &lt;summary&gt;
      /// Initializes a new instance of the MainViewModel class.
      /// &lt;/summary&gt;
      public MainViewModel(IDataService dataService, INavigationService navigationService)
      {
          _dataService = dataService;
          _navigationService = navigationService;
  
          Timesheets = new ObservableCollection&lt;TimesheetViewModel&gt;();
          ExecuteRefreshCommand();
  
      }
  
      public ObservableCollection&lt;TimesheetViewModel&gt; Timesheets
      {
          get;
          private set;
      }
  
      public IEnumerable&lt;TimesheetViewModel&gt; SelectedTimesheets
      {
          get { return Timesheets.Where(o =&gt; o.IsSelected); }
      }
  
      private async void ExecuteRefreshCommand()
      {
          var timesheets = await _dataService.GetTimesheets("domain\\user");
  
          if (timesheets != null)
          {
              Timesheets.Clear();
  
              foreach (var timesheet in timesheets)
              {
                  Timesheets.Add(new TimesheetViewModel(timesheet));
              }
  
          }
      }
  }
  </code></pre>
  
  <p>TimesheetViewModel:</p>
  
  <pre><code>public class TimesheetViewModel: ViewModelBase
  {
  
      public bool IsSelected { get; set; }
  
      public Timesheet Model
      {
          get;
          private set;
      }
  
      public TimesheetViewModel(Timesheet model)
      {
          Model = model;
  
      }
  }
  </code></pre>
  
  <p>If I set the IsSelected property manually, the SelectedTimesheets lambda works, so the problem is somewhere in the binding of the XAML to the IsSelected property.</p>
  
  <p>Any help would be appreciated.</p>