Y
Y
Younus2015-04-04 17:22:16
WPF
Younus, 2015-04-04 17:22:16

How can the ObservableCollection property indicate that an element has been changed?

Hello,
there is a Page object, with the code

public ObservableCollection<VPost> Sourse {
    get {
        return MyData.Sourse;
    }
}

MyData contains the following code
private static ObservableCollection<VPost> myDataGet = new ObservableCollection<VPost>();
private static ObservableCollection<VPost> myDataPhrase = new ObservableCollection<VPost>();
private static ObservableCollection<VPost> myDataGetDb = new ObservableCollection<VPost>();
private string getDataType;

public ObservableCollection<VPost> Sourse {
    get {
        if (getDataType == "getGet") return myDataGet;
        else if (getDataType == "getPhrase") return myDataPhrase;
        else return myDataGetDb;
    }
    set {
        if (getDataType == "getGet" && value != myDataGet)
            myDataGet = value;
        else if (getDataType == "getPhrase" && value != myDataPhrase)
            myDataPhrase = value;
        else if (value != myDataPhrase)
            myDataGetDb = value;
        OnPropertyChanged("Sourse");
    }
}

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged(string propertyName) {
    var handler = PropertyChanged;
    if (handler != null)
        handler(this, new PropertyChangedEventArgs(propertyName));
}

Binding according to the principle DataContext = this; // Page
and then I point to Page.Sourse
When adding elements to MyData.Sourse, nothing changes, I found a similar code, that is, nothing is displayed at all, although I know that MyData.Sourse has been updated. How to solve this problem? thanks in advance.
PS In order not to produce a topic, in WP8.1 I often see at startup, certain applications on the top left, where the WiFi icon, Networks, etc., as if the balls are overbending and the inscription "Loading", how to do this? where to dig, I don’t even know how to call it more correctly in order to google it.
________________________________________________________________________________________________
I solved the problem differently using reflection. thanks to all!
PS about "the balls are overridden and the inscription" Loading "" does no one know how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir S, 2015-04-06
@hePPer

When adding elements to MyData.Sourse, nothing changes, I found a similar code, that is, nothing is displayed at all, although I know that MyData.Sourse has been updated.

your data source is 3 ObservableCollection - most likely, during the primary binding, the connection occurs only with one of the lists.
perhaps instead of a direct link, use something like a ListCollectionView and manually update the ListCollectionView when the collection / desired collection changes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question