C
C
chtyllhu2014-01-04 21:01:20
Windows phone
chtyllhu, 2014-01-04 21:01:20

Binding ListBox for Windows Phone

Good afternoon/evening!
I'll start from afar. There is a textbox and a listbox, when you add text to the textbox, and when you click on the save button, the text should appear in the listbox, everything seems to be fine and even works, but when you restart the application and try to save the text, the application crashes with this error: "Operation not supported on read-only collection". I decided to go the other way, created a class through binding:

public class Text
        {
            public String Note { get; set; }
        }

and collection:
List <Text> myText = new List<Text>()
        {
            new Text()
            {
                Note = "Test"
            };
        }

That's actually the problem, in Note I want to enter data from the textbox, but I can't figure out how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Zolotov, 2014-01-04
@SZolotov

The Text class must inherit from INotifyPropertyChanged, a property of the Text object to notify a change. Why are you using List instead of ObservableCollection? List does not notify the control about changes in the properties of stored objects, use ObservableCollection . In addition, the ObservableCollection collection in which Text objects are stored, just in case, should also notify about the change. If you do everything right, then when you add an object to the ObservableCollection, everything will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question