We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DisplayMemberPath with Multiple Columns not working...

Please advise on how to configure DisplayMemberPath properly when using multiple columns. 

I have a list of Category which each contain sub Categories. I want the picker to display the value of the property "Name" in each column. 

class Category
{
     int Id { get;}
     string Name {get; }
     List<Category> SubCategories { get}
}

List<Category> categories = service.GetCategories();
ObservableCollection<List<Category>> ItemsSource; <-- This is databound to the sfPicker

** Note: this works if I don't set DisplayMemberPath - I see two columns but the type name instead of  Name property
ItemsSource.Add(categories);
ItemsSource.Add(categories.First().SubCategories);

** So the problem is with DisplayMemberPath ** 

1. If I set it to "Name" - this doesn't work as which column/collection is it referring to? The Categories or SubCategories? 
- The Xaml binding fails with error shown below
2. If I bind it to a List<string> { "Name", "Name" } -> The Xaml binding fails with the error shown below
3. If I set DisplayMemberPath in the code behind - it just doesn't do anything and I just see the "TypeName" as the string to select in the picker

Here is the Xaml error I'm getting:
Error  Position 31:18. No property, bindable property, or event found for 'DisplayMemberPath', or mismatching type between value and property.

Thanks in advance!










1 Reply

DR Dhanasekar R Syncfusion Team January 8, 2019 05:19 AM UTC

Hi John, 
 
We have validated your scenario "DisplayMemberPath is not working correctly when using multicolumn picker". We have created the sample based on your requirement in which we have added the Name collection to the DisplayMemberPath and the collection gets updated in the picker column. Please use the below code snippet while setting the DisplayMemberPath. 
 
ObservableCollection<object> collection = new ObservableCollection<object>();
            collection.Add(ViewModel.Countries);

            List<Category> SubCollection = new List<Category>();
            foreach (var item in ViewModel.Countries)
            {
                SubCollection.AddRange(item.SubCategories);
            }
            collection.Add(SubCollection);
            picker.ItemsSource = collection;
            picker.DisplayMemberPath = new ObservableCollection<object>() { "Name", "Name" }; 
 
 
Please refer the below screenshot and sample for your reference.  
 
Screenshot 
 
 
 
 
Please try our above sample and let us know if any further clarifications on this. 
 
Regards, 
Dhanasekar 


Loader.
Live Chat Icon For mobile
Up arrow icon