WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

SyncfusionExamples/how-to-bind-the-list-of-string-to-wpf-data-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to Bind the List of String to WPF DataGrid?

This sample illustrates how to bind the list of string to WPF DataGrid (SfDataGrid).

DataGrid is bound to a collection with a class type. You can bind a list of string as an ItemsSource of DataGrid can be achieved by using GridTemplateColumn.

public class ViewModel
{
    public ViewModel()
    {
        this.DataFieldList = new List<string>() { "Item1", "Item2" , "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10" };
    }

    public List<string> DataFieldList
    {
        get;
        set;
    }
}
<Window.DataContext>
    <local:ViewModel />
</Window.DataContext>
<Grid>
    <syncfusion:SfDataGrid Name="dataGrid"
                            AllowFiltering="False"
                            AllowResizingColumns="False"
                            AutoGenerateColumns="False"
                            ColumnSizer="Star"
                            NavigationMode="Row"
                            ItemsSource="{Binding DataFieldList, UpdateSourceTrigger=PropertyChanged}">
        <syncfusion:SfDataGrid.Columns>
            <syncfusion:GridTemplateColumn HeaderText="Column Name" >
                <syncfusion:GridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" />
                    </DataTemplate>
                </syncfusion:GridTemplateColumn.CellTemplate>
            </syncfusion:GridTemplateColumn>
        </syncfusion:SfDataGrid.Columns>
    </syncfusion:SfDataGrid>
</Grid>

DataGrid bound with List

About

How to bind the list of string to WPF DataGrid(SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8

Languages