Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding DataGrid to a List object Using Visual Studio

$
0
0

Hi There,

Should be very simple thing I just cannot get it right. 

I have following class:

public class NameC 
{
    public string FirstName {get; set; }
    public string LastName {get; set;}
}

public class AddressC
{
    public string Street { get; set; }
    public string City {get; set; }
}

public class Person
{
    public NameC Name {get; set;}
    public AddressC Address {get; set;}
    public string URL {get; set;}
    public DateTime Updated {get; set;}
}

public class Persons : List<Person>
{
}

in MainWindow:

    private Persons list = new Persons();

and a DataGrid called myGrid.

All I wanted is to show the flatten data data in the grid. Just have trouble using the designer.

I figured ItemSource should be myGrid but I don't know how to bind it.

Note:

1. I could easily just do "myGrid.ItemSource = list;" in code that worked find

2. How do setup the columns? also using designer. (Not auto generate)

Thanks,

John



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>