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

Listbox databinding selectedItem

2 Answers 297 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
florian
Top achievements
Rank 1
florian asked on 06 Nov 2017, 02:05 PM

Hello,
I am struggling with listboxes, with something looks quite simple :
<telerik:RadListBox  SelectionMode="Single" x:Name="radListBox" ItemsSource="{Binding Tasks}" SelectedItem="{Binding SelectedPlcTemplate.Task, Mode=TwoWay}" DisplayMemberPath="Name"  />

In my ViewModel:

 public ObservableCollection<PlcTask> Tasks
        {
            get { return PlcTask.GetAll(); }
        }

In my model:

 private PlcTask _task;
        public PlcTask Task
        {
            get
            {
                return _task;
            }
            set
            {
                _task = value;
                RaisePropertyChanged(() => Task);
            }
        }

 

The listbox never updates its value, even if the model is correctlyt updated

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 09 Nov 2017, 11:19 AM
Hello Florian,

Thank you for your interest in RadListBox control.

I couldn't reproduce the behavior that you are experiencing in your application. I have created sample project based on the provided code snippet to test your scenario. You can find the project attached to this reply. When you run the project you can observe that the binding is working as expected. Give this project a try and let me know if I am missing something in order to reproduce this behavior. Also, when you run your application you can double check in the output tab of VS for binding errors.

In addition, you can check the SelectedItemsSource help article in our documentation which describes how you can manipulate the SelectedItems collection in a case when you have multiple selected items.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
florian
Top achievements
Rank 1
answered on 09 Nov 2017, 04:01 PM
Thank you so much for your response, problem solved :)
Tags
ListBox
Asked by
florian
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
florian
Top achievements
Rank 1
Share this question
or