So, I have an application for Windows 8 in which I install some data in defaultViewModel. My question is: after creating the page and I add something to the data, how do I refresh the page and display the changes made?
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { //inital load var DataGroups = SampleDataSource.GetGroups((String)navigationParameter); this.DefaultViewModel["Items"] = DataGroups; } protected override void OnNavigatedTo(NavigationEventArgs e) { //when the page is navigated back to after making changes to sampledatasource base.OnNavigatedTo(e); this.DefaultViewModel.Clear(); var DataGroups = SampleDataSource.GetGroups("AllGroups"); this.DefaultViewModel["Items"] = DataGroups; }
The changes I make are not reflected until the next time I open the application and the page reloads. Here is a view model:
protected IObservableMap<String, Object> DefaultViewModel { get { return this.GetValue(DefaultViewModelProperty) as IObservableMap<String, Object>; } set { this.SetValue(DefaultViewModelProperty, value); } }
This is the list I would like to update:
<ListView x:Name="itemListView" AutomationProperties.AutomationId="ItemsListView" AutomationProperties.Name="Items" TabIndex="1" Grid.Row="1" Visibility="Collapsed" Margin="0,-10,0,0" Padding="10,0,0,60" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" ItemTemplate="{StaticResource Standard80ItemTemplate}" SelectionMode="None" IsSwipeEnabled="false" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick"/>
Related to this:
<CollectionViewSource x:Name="itemsViewSource" Source="{Binding Items}" d:Source="{Binding AllGroups[0].Items, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
Msdn function:
public void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
source share