P.Brian.Mackey
P.Brian.Mackey

Reputation: 44285

Autogenerate Columns from data in grid control

I set the datasource for a WPF dxg:GridControl to that of a hard coded list.

        gridControl1.ItemsSource = new List<Entity> { new Entity() { Name = "1" }, new Entity() { Name = "2" }, new Entity() { Name = "3" } };

I have to specify each column in the XAML:

        <dxg:GridControl.Columns>
            <dxg:GridColumn FieldName="Name" Name="gridColumn1" />
            <dxg:GridColumn FieldName="Column2" Name="gridColumn2" />
        </dxg:GridControl.Columns>

How can I get the columns to autogenerate instead of specifying XAML?

I tried removing the columns. That displayed nothing. The data actually comes from a WCF service at runtime, so the "Populate Columns" button in design mode is probably not going to work either.

Upvotes: 2

Views: 1447

Answers (1)

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26078

A bit of a stab in the dark, but other grids in WPF usually have something like this...

<dxg:GridControl AutoPopulateColumns ="True">

(edit to get actual property name)

Upvotes: 1

Related Questions