locked
How to use INotifyCollectionChanged to update a grid item and its collection list ?

    Question

  • i was using INotifyPropertyChanged but it was not updating the collection list on the UI, so how can i update the group title and its list of items at runtime ?

    19karabo91

    Friday, February 14, 2014 1:37 PM

All replies

  • Can you please provide more details on what you are doing? Can you share on SkyDrive a minimal sample demonstrating how you are updating your collection?

    Friday, February 14, 2014 3:58 PM
    Owner
  • this is my viewmodel

    public class MeetingOrganiserPageViewModel : INotifyPropertyChanged
    	{
    		IDataRepository _data;
    
    		public MeetingOrganiserPageViewModel()
    		{
    			IDataRepository data = new FileRepository();
    			_data = data;
    		}
    
    		public MeetingOrganiserPageViewModel(IDataRepository data)
    		{
    			_data = data;
    		}
    
    		async public void Initialize()
    		{
    			Boards = await _data.Load();
    		}
    
    		private Board selectedItem;
    		public Board SelectedItem
    		{
    			get { return this.selectedItem; }
    			set
    			{
    				if (value != selectedItem)
    				{
    					selectedItem = value;
    					RaisePropertyChanged();
    				}
    			}
    		}
    
    		private ObservableCollection<BoardCategory> boards;
    		public ObservableCollection<BoardCategory> Boards
    		{
    			get { return boards; }
    			set
    			{
    				boards = value;
    				RaisePropertyChanged();
    			}
    		}
    
    		internal bool Exists(Board board)
    		{
    			return _data.Exists(board);
    		}
    
    		internal void AddBoard(Board board)
    		{
    			_data.Add(board);
                foreach (BoardCategory item in Boards)
                {
                   List<Board> newBoard = item.Items ;
                   RaisePropertyChanged("newBoard");
                }
    		
    		}
    
    		internal void DeleteBoard(Board board)
    		{
    			_data.Remove(board);
    			RaisePropertyChanged();
              
    		}
    
    
            public event PropertyChangedEventHandler PropertyChanged;
            public void RaisePropertyChanged(
                [CallerMemberName] string caller = "")
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(caller));
                }
            }
    
    
        }

    And the BoardCategory has this class that is binding to the UI

    public class BoardCategory
    	{
    		public string Title { get; set; }
    		public List<Board> Items { get; set; }
    	}

     

    19karabo91

    Monday, February 17, 2014 6:34 AM