This is a migrated thread and some comments may be shown as answers.

How to bind to data source?

4 Answers 152 Views
CheckBox
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 19 Oct 2018, 04:50 PM

I cannot for the life of me get IsChecked to bind properly to a data source so I can't use it against a model. How is one supposed to do it? This doesn't work:

IsChecked="{Binding Selected}"

 

4 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 22 Oct 2018, 08:03 AM
Hello,

In order to control the sate of the RadCheckeBox from ViewModel in the most basic scenario, there are two requirements. First is the property in your ViewModel to invoke the Propertychanged event and the other is to bind the RadCheckBox.IsChecked property in TwoWay mode.

More information can be found in the XAML basics series.

Regards,
Pavel R. Pavlov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
1
James
Top achievements
Rank 1
answered on 23 Oct 2018, 12:04 PM
I've done all of that and the PropertyChanged event is fired on whatever it's bound to, but it isn't the BindingContext of the ContentPage that is at the root. It appears to be some sort of copy because when you access the BindingContext the value that was clearly changed in the PropertyChanged event is not changed.
0
Pavel R. Pavlov
Telerik team
answered on 23 Oct 2018, 12:43 PM
Hi James,

I tired to reproduce the issue on our side to no avail. The binding works as expected in a straightforward setup. There should be something different causing the reported issue.

Could you please try to reproduce it in a small repro project that uses only our components and send it over? This will allow us to investigate the reasons behind the reported behavior. Also we will be able to suggest a way to approach this case.

I am looking forward to hearing from you.

Regards,
Pavel R. Pavlov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
n/a
Top achievements
Rank 1
Iron
answered on 04 Oct 2023, 09:16 AM | edited on 04 Oct 2023, 09:43 AM

I got the same behavior as mentioned.
When I change state of checkbox, I see in ItemViewModel that IsChecked is changed.
But after that when I access main ObservableCollection, IsChecked for specified item is not changed.
So View must make copy instances of bounded ObservableCollection.
When I bind PropertyChanged event to all list items, it is not called too.

I see it is related to ThreeState option.

Yana
Telerik team
commented on 06 Oct 2023, 07:09 AM

Hi Maciej,

As I understand from the provided information, you're using a three-state CheckBox inside an items control, such as ListView. I've tried to reproduce the described behavior with not properly updating of the underlying values,  still this works as expected in a simple setup on my side.

I've attached my test app as a reference, can you download it and give it a try? Can you check what's different in your setup and provide more details/some sample code about the exact scenario you have?

Tags
CheckBox
Asked by
James
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
James
Top achievements
Rank 1
n/a
Top achievements
Rank 1
Iron
Share this question
or