Silverlight datagrid fails to display data.
- by Jekke
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?