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

Binding ItemsSource to a simple ObservableCollection<string>

I would like to bind my datagrid to a simple ObservableCollection<string> to have a basic support of automatic insertion/deletion of strings in a list.
The following is the code I used.

<sfGrid:SfDataGrid AddNewRowPosition="Bottom"
                   ItemsSource="{x:Bind StringList}" />
Code Behind:
public ObservableCollection<string> StringList => new ObservableCollection<string> { "abc""def""123"};

not really what I was expecting...
How can I bind to a simple ObservableCollection<string> without DataGrid to try to get String Properties and display them, but actually use the basic string?

4 Replies

SP Sowndaiyan Paulpandi Syncfusion Team September 21, 2016 04:18 PM UTC

Hi Luca

Thanks for contacting Syncfusion Support.

In SfDataGrid, you can display the string properties using the GridTemplateColumn when the SfDataGrid is bound to string collection. But it is not possible to add new records using AddNewRow and also it is not possible to edit the records. However you can able to add the item from code behind and also you can delete the records by setting the SfDataGrid.AllowDeleting property as true. We have prepared  a sample as per your requirement and you can download the sample from the below location,

Sample : http://www.syncfusion.com/downloads/support/forum/126058/ze/UWP-661448407


LS Luca Spolidoro September 23, 2016 01:09 AM UTC

Thanks Sowndaiyan,
with your suggestion I was able to implement the simple string databinding.
I had to add a textbox to support Add new item, but it's fine (deletion fortunately it's supported)

SV Srinivasan Vasu Syncfusion Team September 23, 2016 10:01 AM UTC

Hi Luca, 

Thanks for your update. 

SV Srinivasan Vasu Syncfusion Team September 23, 2016 10:06 AM UTC

Hi Luca, 
Please let us know if you need further assistance on this. 

Live Chat Icon For mobile
Up arrow icon