0

In my windows store app I have a gridview with data source set to Observable collection. When the item is added or removed to the collection everything works fine and view is updated. However when property of item of the collection is changed, the collectionChanged event is not fired and the views is not updated. I found a solution how to use INotifyChanged and propertyChanged event, but I want to fluidly update the view without doing something as reassigning the data source of gridview in propertyChanged Handler.

So I want to ask, if there is any solution to this problem.

Thank You in advance.

marek_lani
  • 3,895
  • 4
  • 29
  • 50
  • What would you like to happen when a property of an item changes? If the property is observable (raises the `PropertyChanged` event of the `INotifyPropertyChanged` interface when the value changes) - anything bound to that property should get updated. – Filip Skakun Mar 25 '14 at 19:12
  • Well I have Collection bounded to ListView and when the collection is changed the listview updates. However when only the item of collection is changed, the view does not update. So I do not have single items bounded but whole collection. Does the rising of PropertyChanged event help also in this case? Because I tried it and it did not work, but maybe I made a mistake. – marek_lani Mar 27 '14 at 08:37

1 Answers1

-1

Refer the below code snippet, to notify while collection changed.

  public class MyClass : INotifyPropertyChanged
    {
        private ObservableCollection<double> _myCollection;

        public ObservableCollection<double> MyCollection
        {
            get { return _myCollection; }
            set
            { 
                _myCollection = value;
                RaisedOnPropertyChanged("MyCollection");
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        public void RaisedOnPropertyChanged(string _PropertyName)
        {
            if (PropertyChanged!=null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(_PropertyName));
            }
        }
    }

Hope it will help you..!

Regards, Joy Rex

Joy Rex
  • 608
  • 7
  • 32