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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding ItemsSource to a simple ObservableCollection<string>

Thread ID:

Created:

Updated:

Platform:

Replies:

126058 Sep 21,2016 02:36 AM UTC Sep 23,2016 10:06 AM UTC UWP 4
loading
Tags: SfDataGrid
Luca Spolidoro
Asked On September 21, 2016 02:36 AM UTC

hello,
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.

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

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?

Sowndaiyan Paulpandi [Syncfusion]
Replied On 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


Regards,
Sowndaiyan


Luca Spolidoro
Replied On 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)

Srinivasan Vasu [Syncfusion]
Replied On September 23, 2016 10:01 AM UTC

Hi Luca, 

Thanks for your update. 
  
Please  
Regards, 
Srinivasan 


Srinivasan Vasu [Syncfusion]
Replied On September 23, 2016 10:06 AM UTC

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;