I have built a prototype Forms App for Android. It's a potential replacement for a WebForms app. The concept is, I begin with a JSON file (as a datasource) for local non-internet functionality. This is a READ-ONLY file, from the users perspective... The data is retrieved and updated as needed from a web service... (the url is contained within each JSON Entity... When the app opens, there is default JSON information the app can start with... Then, there is a date field and some ModelView logic that retrieves new data as needed, and is updated in the "live" entity (that which was loaded initially). When the app Sleeps or Stops the current ObservableCollection is serialized to JSON, with any subsequent data changes and the file itself is saved...
Everything works as expected... Except... In the json file there are approximately 7 primary entities. Only 4 of them require regular updates because they have hot changing information... This I wish to display in a subset on the startup Navigation page in a marquee... I have all the bits in place and it all works, BUT only when the full list is queried...
ModelView (psuedo code)
PrimaryList = new ObservableCollection(FileOperastions.GetFullPrimaryLIst());
// GetFullPrimaryList returns a "list of primary model" items. I then bind this list to the binding context of the view, add it to the CarouselView in Xamarin and Walla! It works... As the background code on the primary thread executes, the Observable entities are updated from the URLs in the entity, and the displays are changed, viewable and subsequently saved... Perfect!
The problem appears to happen when I use a select query for only the 4 primary items that require notification... So;
PrimaryList = new ObservableCollection(FileOperastions.GetFullPrimaryLIst().Where(l => l.infourl.Contains("http")).ToList());
- My list now contains just the 4 entities in question as desired.
- The CarouselView displays these 4 entities as desired, and SOME of the entities show updates while others do not.
- Breakpoints in the WebClient DownloadStringAsync callback verify that the data is properly retrieved and the entity is updated properly...
- But, the data is not shown, as it is when the full list is in place...
has anyone else run into this issue? Do I need to raise a CollectionChanged event here... It's odd it does not work for a subset, but works for the full list... In terms of code... I change NOTHING else other than the line of code displayed above... I have tried creating a separate function of course, but whether it is a linq query as above or a function that returns a NEW list makes no difference... the result is the same... however, this also breaks the MVVM construct I am trying to stay within...