J
J
John2020-12-10 09:18:25
WPF
John, 2020-12-10 09:18:25

Wpf why doesn't binding ListBox CheckBox work?

I can’t understand why set doesn’t work ... When the window is loaded, the listbox is filled, which means get works. Back and forth is in vogue. Maybe someone will give you an idea? I feel that "the truth is somewhere nearby", but the thought does not come.

<ListBox ItemsSource="{Binding Path=Dayweek, Mode=TwoWay}">
   <ListBox.ItemTemplate>
      <DataTemplate>
         <CheckBox Content="{Binding Path=Text}" IsChecked="{Binding Path=Check, Mode=TwoWay}"/>
      </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

public ObservableCollection<CheckText> Dayweek
        {
            get
            {
                .........
            }
            set
            {
                .........
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soloveid, 2020-12-10
@soloveid

Why do you think set should work?
It shouldn't work. Therefore, you can simply put Mode=OneWay.
If it worked, it means that the ListBox initialized the ItemsSource with a
new ObservableCollection, I don't even know, it's kind of impossible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question