title: Creating grouped gridview and binding Observable collection data after grouping but no INotifyProperty Change is affecting the grid?
body: <p>I am trying to make a grouped gridview in Windows 8 application I have a class named book whose ObservableCollection I have made in my ViewModel class for that page. But I need to group the data when I am trying to group and bind the data on my codebind file of XAML and then binding there is no effect of INotifyProperty happening. Please suggest how can I achieve this in my VW?</p>
  
  <p>Code Below:</p>
  
  <p>Code Behind of XAML:</p>
  
  <pre><code> protected override void LoadState(Object navigationParameter,
                                                 Dictionary&lt;String, Object&gt; pageState)
          {
              MainViewModel booksList = new MainViewModel();
              var teamGroups = booksList.BooksDetail.GroupBy(team =&gt; team.BookCategory)
                                             .OrderBy(team =&gt; team.Key.ToString());
  
              this.groupedItemsViewSource.Source = teamGroups;
          }
  </code></pre>
  
  <p>View Model Class:</p>
  
  <pre><code>  #region BooksDetail Collection
          /// &lt;summary&gt;
          /// The &lt;see cref="BooksDetail" /&gt; BooksDetail
          /// &lt;/summary&gt;
          public const string BooksDetailPropertyName = "BooksDetail";
  
          private ObservableCollection&lt;Book&gt; _booksDetailProperty = new ObservableCollection&lt;Book&gt;();
  
          /// &lt;summary&gt;
          /// Gets the BooksDetail property.
          /// TODO Update documentation:
          /// Changes to that property's value raise the PropertyChanged event. 
          /// This property's value is broadcasted by the Messenger's default instance when it changes.
          /// &lt;/summary&gt;
          public ObservableCollection&lt;Book&gt; BooksDetail
          {
              get
              {
                  return _booksDetailProperty;
              }
  
              set
              {
                  if (_booksDetailProperty == value)
                  {
                      return;
                  }
  
                  _booksDetailProperty = value;
  
                  // Update bindings, no broadcast
                  RaisePropertyChanged(BooksDetailPropertyName);
              }
          }
          #endregion
  
    public void GetBooksDetail()
          {
  
                  try
                  {
                      // Check if the code is in Design Mode or Running Mode
                      if (ViewModelBase.IsInDesignModeStatic)
                      {
                          // Created the object of main model class
                          DesignMainModel mainModel = new DesignMainModel();
  
                          // Call method to get list of books detail
                          this.BooksDetail = mainModel.GetBooksDetailData();
                      }
                      else
                      {
                          // Check for internet connectivity 
                          if (Utility.IsInternetAvailable())
                          {
                              //TODO: Write the logic to to implement in Running Mode
                              // Created the object of main model class
                              DesignMainModel mainModel = new DesignMainModel();
  
                              // Call method to get list of books detail
                              this.BooksDetail = mainModel.GetBooksDetailData();
  
                              // Group by data on Book Category
                              this.GroupByBookDetailsOnCategory();
                          }
                          else
                          {
                              // Display Error Message for No internet Connection available
                              util.ShowUserMessage(App.GeneralMessageResource.GetString("InternetConnectionErrorMessage"), App.GeneralMessageResource.GetString("InternetConnectionErrorCategory"));
                          }
                      }
  
                  }
                  catch (Exception ex)
                  {
                      // Display the error
                      util.ShowUserMessage(ex.Message, App.GeneralMessageResource.GetString("GeneralErrorTitle"));
                  }
              }
          }
  </code></pre>
  
  <p>Books Class:</p>
  
  <pre><code>   #region BookCategory Property
          /// &lt;summary&gt;
          /// The &lt;see cref="BookCategory" /&gt; property's name.
          /// &lt;/summary&gt;
          public const string BookCategoryPropertyName = "BookCategory";
  
          /// &lt;summary&gt;
          /// The _book category property
          /// &lt;/summary&gt;
          private string _bookCategoryProperty = string.Empty;
  
          /// &lt;summary&gt;
          /// Gets the BookCategory property.
          /// TODO Update documentation:
          /// Changes to that property's value raise the PropertyChanged event. 
          /// This property's value is broadcasted by the Messenger's default instance when it changes.
          /// &lt;/summary&gt;
          public string BookCategory
          {
              get
              {
                  return _bookCategoryProperty;
              }
  
              set
              {
                  if (_bookCategoryProperty == value)
                  {
                      return;
                  }
  
                  _bookCategoryProperty = value;
  
                  // Update bindings, no broadcast
                  RaisePropertyChanged(BookCategoryPropertyName);
              }
          }
          #endregion
  </code></pre>
  
  <p>Changed as per the input:
  I have created an ObservableCollection of Tuple. But now when I am binding it to CollectionViewSource then no list is getting populated. Please refer the code below: Let me know where I am making mistake:</p>
  
  <p>XAML:
       </p>
  
  <pre><code>&lt;GridView Grid.Row="1" Margin="5,0,0,0" Grid.Column="1"
           x:Name="itemGridView"
           SelectionMode="Multiple"
           ItemTemplate="{StaticResource CategoryLists}"
           ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
             ItemContainerStyle="{StaticResource CategoryListsStyle}"&gt;
      &lt;GridView.GroupStyle&gt;
                  &lt;GroupStyle&gt;
                      &lt;GroupStyle.HeaderTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Grid&gt;
                                  &lt;StackPanel Orientation="Horizontal" Margin="15,0,0,0"&gt;
                                      &lt;TextBlock Text="{Binding Key}" Margin="0,-5,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Segoe UI Regular" Foreground="#00bfff" FontSize="27"/&gt;
                                      &lt;!--&lt;TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/&gt;--&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/Grid&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/GroupStyle.HeaderTemplate&gt;
                      &lt;GroupStyle.Panel&gt;
                          &lt;ItemsPanelTemplate&gt;
                              &lt;VariableSizedWrapGrid Orientation="Vertical" Margin="10,-1,35,0"/&gt;
                          &lt;/ItemsPanelTemplate&gt;
                      &lt;/GroupStyle.Panel&gt;
                  &lt;/GroupStyle&gt;
              &lt;/GridView.GroupStyle&gt;
  
  &lt;/Grid&gt;
  </code></pre>
  
  <p>Property:
      #region BooksDetailGrouped Collection
              /// 
              /// The  property's name.
              /// 
              public const string BooksDetailGroupedPropertyName = "BooksDetailGrouped";</p>
  
  <pre><code>        /// &lt;summary&gt;
          /// The _books detail grouped property
          /// &lt;/summary&gt;
          private ObservableCollection&lt;Tuple&lt;string, ObservableCollection&lt;Book&gt;&gt;&gt; _booksDetailGroupedProperty = new ObservableCollection&lt;Tuple&lt;string, ObservableCollection&lt;Book&gt;&gt;&gt;();
  
  
  
          /// &lt;summary&gt;
          /// Gets the BooksDetailGrouped property.
          /// TODO Update documentation:
          /// Changes to that property's value raise the PropertyChanged event. 
          /// This property's value is broadcasted by the Messenger's default instance when it changes.
          /// &lt;/summary&gt;
          public ObservableCollection&lt;Tuple&lt;string, ObservableCollection&lt;Book&gt;&gt;&gt; BooksDetailGrouped
          {
              get
              {
                  return _booksDetailGroupedProperty;
              }
  
              set
              {
                  if (_booksDetailGroupedProperty == value)
                  {
                      return;
                  }
  
                  _booksDetailGroupedProperty = value;
  
                  // Update bindings, no broadcast
                  RaisePropertyChanged(BooksDetailGroupedPropertyName);
              }
          }
          #endregion
  </code></pre>
  
  <p>Method to group:</p>
  
  <pre><code>// Grouping the data
              var booksGroup = this.BooksDetail.GroupBy(books =&gt; books.BookCategory)
                                              .OrderBy(books =&gt; books.Key.ToString());
  
              // Convert grouped data to ObservableCollection&lt;Tuple&lt;string, ObservableCollection&lt;Book&gt;&gt;&gt;
              this.BooksDetailGrouped = new ObservableCollection&lt;Tuple&lt;string, ObservableCollection&lt;Book&gt;&gt;&gt;(
              booksGroup.Select(x =&gt; Tuple.Create(x.Key,
                                              new ObservableCollection&lt;Book&gt;(x))));
  </code></pre>