Listbox databinding selectedItem

3 posts, 0 answers
  1. florian
    florian avatar
    7 posts
    Member since:
    Nov 2017

    Posted 06 Nov 2017 Link to this post

    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. Dinko
    Admin
    Dinko avatar
    475 posts

    Posted 09 Nov 2017 Link to this post

    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.
  3. florian
    florian avatar
    7 posts
    Member since:
    Nov 2017

    Posted 09 Nov 2017 Link to this post

    Thank you so much for your response, problem solved :)
Back to Top