views:

28

answers:

1

This is driving me nuts. I have a datagrid in WPF that is not populating with records at runtime.

Here is the XAML. I've done this before in Silverlight although I am a newbie and can't quite figure out what is missing.

<DataGrid AutoGenerateColumns="True" Height="335" HorizontalAlignment="Left" Name="DataGrid1" VerticalAlignment="Top" Width="753">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Date" Width="175" Binding="{Binding DateTimePosted}"/>
            <DataGridTextColumn Header="Name" Width="275"  Binding="{Binding Name}"/>
            <DataGridTextColumn Header="Debit" Width="100"  Binding="{Binding DebitAmout}" />
            <DataGridTextColumn Header="Credit" Width="100"  Binding="{Binding CreditAmount}" />
            <DataGridTextColumn Header="Balance" Width="100"  Binding="{Binding Balance}" />
        </DataGrid.Columns>
    </DataGrid>

In code in the loading event I do the following.

DataGrid1.DataContext = Facade.GetTransactions

this returns a list of TransactionItems (custom object) that have public properties matching the fields I am binding in the datagrid XAML.

I've checked and ensured 74 records are being returned.

The grid is still showing up as blank. I'm going bonkers as I can't find an example that is showing me what I can do to correct this.

WPF 4.

I've tried AutoGenerateColumns = True and = False... no diff

Advice

+1  A: 

I think you need to use the ItemsSource property, not the DataContext property.

Craig Eddy
I'm a douche. You are the man! It worked. I'm a WPF newbie.
Marko
Nah, just too many similarly-named properties on that beast.
Craig Eddy