How to set Visibility of GridView when incrementalSource returns null RRS feed

  • Question

  • Hi,

    I am developing Windows 8 Store app. In this am using MVVM pattern to fetch data from web server. I am able to do it in infinite scrolling way and working fine.
    Now  i want to set visibility of Grid view to collapsed, when web server returns zero items. 
    Is there is any way to bind visibility to IncrementalSourc ?

    I am using this

    public class IncrementalSource<T, K> : ObservableCollection<K>, ISupportIncrementalLoading

    and setting Grid view itemSource to MainViewModel

    this.itemGridView.ItemsSource = new IncrementalSource<Artists_MainViewModel,Artists_ItemViewModel>(10);

    Monday, November 25, 2013 12:14 PM


  • You can encapsulate the IncrementalSource in the another class say "MainDataViewModel" and add the property on that class to control the visibility of GridView.  Something like this - 

    public class MainDataViewModel {

    public IncrementalSource<Artists_MainViewModel,Artists_ItemViewModel> Artists { get; set; }

    public Visibility ArtistsVisibile { get { return (Artists.Count > 0 ? Visibility.Visible : Visibility.Collapsed); } }


    * Just typed the class here, so there could be some syntax error.

    Now just the datacontext for GridView parent to object of MainDataViewModel and bind the properties Artists and ArtistsVisible accordingly. 

    Thanks, Sachin

    • Marked as answer by Anne Jing Friday, November 29, 2013 6:04 AM
    Monday, November 25, 2013 2:39 PM