Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a GridView after adding an item to a nested list
    text
    copied!<p>While I was developing a startscreen for my app using the GridView control, I run into a problem. I have a GridView on my main screen which has a CollectionViewSource set as ItemSource. </p> <p>For this CollectionViewSource the source is set to an ObservableCollection list. Each GroupViewModel has a ObservableCollection in it. In code the important parts looks like the following:</p> <pre><code>public class StartPageViewModel : ViewModelBase { public ObservableCollection&lt;GroupViewModel&gt; Groups { get; set; } public CollectionViewSource GroupsCvs { get; set; } public StartPageViewModel() { // fill Groups with some mock data GroupsCvs.Source = Groups; GroupsCvs.IsSourceGrouped = true; } public void MoveItems(GroupViewModel grp) { // add a dummy item grp.AddRecipe(new ItemViewModel(new Item()) { Id = "123" }); RaisePropertyChanged("GroupsCvs"); RaisePropertyChanged("Groups"); } } public class GroupViewModel : ViewModelBase, IEnumerable&lt;ItemViewModel&gt; { public ObservableCollection&lt;ItemViewModel&gt; Items { get; set; } } View: public sealed partial class MainPage : LayoutAwarePage { private ViewModelLocator locator = new ViewModelLocator(); public MainPage() { this.InitializeComponent(); this.DataContext = locator.Main; // returns StartPageViewModel } } XAML part for MainPage, GridView &lt;GridView ItemsSource="{Binding GroupsCvs.View}" ... &lt;/GridView&gt; </code></pre> <p>How is it possible to get the UI refreshed when I add an Item to a Group's collection? In my StartPageViewModel I'm adding dummy item to the GroupViewModel and I raise propertychanged, but the Grid remains the same.</p> <p>I've also tried to fire property changed event in the GroupViewModel class, when the Items collection changes without any luck.</p> <p><strong>Edit:</strong> As I wrote in comments it's possible to refresh with reassigning the source property however this gets the GridView rendered again which is not nice. I'm looking to options which would result in a nicer user experience.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload