Tuesday, September 3, 2013

Refresh datasource collection

I have a login page that different user login navigates to the GroupedItemPage that display different item. But currently when I run the app it only display the first user item. After I logout and login as different user it still displays the previous user data. How do I let it refresh cause after I setting breakpoints on the GroupedItemPage when it reach a point it goes to the datasource to get the collection. But the first time it goes to this code:



private static VMDataSource _vmDataSource = new VMDataSource();

private ObservableCollection<VMDataGroup> _allGroups = new ObservableCollection<VMDataGroup>();
public ObservableCollection<VMDataGroup> AllGroups
{
get { return this._allGroups; }
}

public static IEnumerable<VMDataGroup> GetGroups(string uniqueId)
{
if (!uniqueId.Equals("AllGroups")) throw new ArgumentException("Only 'AllGroups' is supported as a collection of groups");
return _vmDataSource.AllGroups; //first time it is null, after i logout and login as different user it have already have the previous data and skip the public VMDataSource() {}
}

The first time I login the return _vmDataSource.AllGroups is null but the second time I login it is not null so it it keep displaying me the wrong data unless I restart the app. And also does the cache store the settings charm cause it keeps creating a new buttons after I signout and login again. Thanks.



Thanks, Smiths



No comments:

Post a Comment