CMarinacci
Topic Author
Posts: 15
Joined: 07 Aug 2017, 02:56

Binding to ObservableCollection elements not always working when ObservableCollection is modified (Unity 2.1.0rc3)

06 Mar 2018, 01:01

I bound some controls to the indexed elements of an ObservableCollection. When the ObservableCollection was modified, the controls were not always updated. WPF handles this case correctly.

I've attached a ZIP file containing a couple of solutions that show this behavior:

BindingTest.sln: A Unity version of the program (you will need to import NoesisGUI and load the scene "Main" before running the program).
BindingTest XAML.sln: A WPF version of the program.

There are two sets of controls that are bound to the first 4 items of an ObservableCollection of strings. The first set are ContentControls that use a DateTemplate, and the second set are TextBlocks. The behavior of each set is slightly different.

There are two buttons to press:

"Make item 3 null": This works correctly with the TextBlock set, but not the ContentControl set. The TextBlock corresponding to the now null item is blanked out, but the ControlControl isn't.

"Remove item 0": This doesn't work correctly with either set. The first control in each set is updated correctly, but the others aren't, except when the button is pressed four times to remove the last item (now in position 0) -- the first TextBlock is updated correctly, but the first ContentControl isn't.

The WPF version of the program handles these cases correctly.

Let me know if you need any more information.

Thanks,

Chris
Attachments
BindingTest.zip
(37.74 KiB) Downloaded 270 times

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 86 guests