Silverlight datagrid fails to display data.

Posted by Jekke on Stack Overflow See other posts from Stack Overflow or by Jekke
Published on 2010-03-11T16:49:52Z Indexed on 2010/03/11 17:24 UTC
Read the original article Hit count: 321

Filed under:
|

I have a datagrid defined in my project's XAML:

        <data:DataGrid IsReadOnly="True" Grid.Row="1" Grid.Column="1" x:Name="gridOfferings"
                       Margin="10,10,10,10" AutoGenerateColumns="False">
            <data:DataGrid.Columns>
                <data:DataGridTextColumn 
                Binding="{Binding Trader}"
                DisplayIndex="0"
                Header="Trader" 
                Width="Auto"
                FontSize="11"/>
            <data:DataGridTextColumn 
                Binding="{Binding Product}"
                DisplayIndex="1"
                Header="Product" 
                Width="Auto"
                FontSize="11"/>
            </data:DataGrid.Columns>
        </data:DataGrid>

I bind it to a List<> of custom objects:

    public MainPage()
    {
        InitializeComponent();

        _Rows = new List<OfferingRowData>();

        _Rows.Add(new OfferingRowData()
        {
            Trader = "Kameilya Loenstein",
            Product = "American Consolidated AAA",
            Price = 24.95,
            OfferingMade = DateTime.Now
        });

        _Rows.Add(new OfferingRowData()
        {
            Trader = "Bill Foobar",
            Product = "IBM Mid-Atlantic Exotic",
            Price = 204.90,
            OfferingMade = DateTime.Now.AddMinutes(-3)
        });

        gridOfferings.ItemsSource = _Rows;

    }

When it shows up on the page, the column headers appear, but none of the data does.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about datagrid