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

Synchronize SelectedItem between two lists

1 Answer 117 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Breno
Top achievements
Rank 1
Breno asked on 21 Mar 2017, 01:10 PM

Hello everyone!

I’ve created two RadListView on a MasterDetailPage (Xamarin Forms), one on master (side menu) and another on detail page. When I select an item on master, I expect a visible selection on detail item. Both lists have the same items, so that’s the reason that I want to synchronize them. 

My problem is when I tap an Item on master’s list, I can’t mirror the selection (selectedItem) on Detail’s list. I expect a visible selection on detail item, once I tap the correspondent on master. If I tap an item on detail, it’s visibly selected. If I tap again on the same item, it’s unselected, and these behaviors are ok.

I tried using the article’s solution below, but the behavior that I want is to keep the item selected once I tap the item on master. 

http://www.telerik.com/forums/how-to-deselect-radlistview-item

Let me show some code… The binding was made at code-behind, in the ViewModel:

this.SetBinding<IMenuPageViewModel>(DepententListView.SelectedItemProperty, vm => vm.SelectedDependent, BindingMode.TwoWay);

This one is the Property's ViewModel:

public IUser SelectedDependent
{
      get { return _selectedDependent; }
      set
      {
        if (_selectedDependent != value)
        {
          _selectedDependent = value;
          RaisePropertyChanged();
        }
      }
    }

}

And this one is the method that I try to change the selection:
public void ChangeDependent(IUser dependent)
{
   // I expect the item selection change here...
   this.SelectedDependent = dependent;

   // Trying force change...
   RaisePropertyChanged("SelectedDependent"); 
}

In the beginning, I thought the RadListView had a bug, but I send this to clarify if in fact is. In Xamarin.Forms’ ListView works fine.

Can anyone help me with this issue?

 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 24 Mar 2017, 01:51 PM
Hi Beno,

Thank you for contacting us.

You can update the listview selected items programmatically by modifying the SelectedItems collection. Unfortunately, there is an issue on Android and adding items to the collection does not update the visual state of the items in the listview. I have logged this issue in our feedback portal where you can track its status. I have attached a sample that demonstrates how this could work on iOS. Please, take a look and let us know if you have further questions.

Regards,
Rosy Topchiyska
Telerik by Progress
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
Tags
ListView
Asked by
Breno
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or