- Home
- Forum
- Xamarin.Forms
- DisplayMemberPath not working with Arrays
DisplayMemberPath not working with Arrays
Hi,
I want to add a list of classes at the DataSource and the class has a string[] property with name "Entries".
For example in the SfDataGrid I add as MappingName = "Entries[0]" and the Cell references to any_object.Entries[0].
I hoped that it works simliar to DisplayMemberPath but I got not the same successful result.
Does anybody has a hint?
My code:
...
_comboBox = new SfComboBox();
_comboBox.IsEditableMode = false;
_comboBox.MaximumDropDownHeight = 200;
_comboBox.HeightRequest = 40;
Entries = new ObservableCollection<SelectionViewEntry>();
_comboBox.DataSource = this.Entries;
_comboBox.DisplayMemberPath = "Entries[0]";
...
public class SelectionViewEntry
{
public string[] Entries { get; set; }
}
SIGN IN To post a reply.
3 Replies
PA
Paul Anderson S
Syncfusion Team
November 21, 2018 12:07 PM UTC
Hi Thomas Loidolt,
Greetings from Syncfusion.
We checked the given code snippet and when using String [] type for the data source it returns only the array object. We have also tested the same String [] type data with the ListView control and it also returned only the array object. We have prepared a sample on how to use a collection of a custom class and display the desired property using DisplayMemberPath. Please find the sample from the below link.
Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/Combo_Sample229325923
For more information about using “DisplayMemberPath” property is given below:
Please check our sample and let us know if you have any concerns.
Regards,
Paul Anderson
TL
Thomas Loidolt
November 21, 2018 03:40 PM UTC
Hi,
your solution is not working for my requirements but I found another way to solve it:
public class SelectionViewEntry
{
public int ColumnIndex { get; set; }
public string Entry { get => Entries[ColumnIndex]; set => Entries[ColumnIndex] = value; }
public string[] Entries { get; set; }
}
And this is a working example of SfDataGrid and MappingName:
_dataGrid.Columns.Add(new GridTextColumn() { MappingName = "Features[" + i.ToString() + "]", HeaderText = item.Value.Value, TextAlignment = item.Value.HorizontalAlignment, FontAttribute = FontAttributes.Bold });
BR,Thomas
PA
Paul Anderson S
Syncfusion Team
November 22, 2018 04:23 AM UTC
Hi Thomas,
Thanks for the update. We are glad that you have achieved your requirement. Please get in touch if you required further assistance.
Regards,
Paul Anderson
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TL Thomas Loidolt
- Nov 20, 2018 10:29 AM UTC
- Nov 22, 2018 04:23 AM UTC