i know it must something simple that i missed. I use data services to get data into my silverlight application. When i bind the data to my datagrid it works like a charm
LessonGrid.ItemsSource = context.Lessons
however as soon as i try to wrap my objects into more complex data structure it stops working
LessonGrid.ItemsSource = context.Lessons.Select(l => new {Lesson = l; Color=Colors.Yellow})
I tried to define binding with path and without and doesn't seem to work
<data:DataGridTextColumn Header="Date" Binding="{Binding StartTime}"/>
<data:DataGridTextColumn Header="Date" Binding="{Binding StartTime, Path=Lesson.StartTime}"/>
<data:DataGridTextColumn Header="Date" Binding="{Binding Path=Lesson.StartTime}"/>
<data:DataGridTextColumn Header="Date" Binding="{Binding StartTime, Path=Lesson}"/>
Suggestions?
After more more research:
Ok,it's nothing to do with complex objects. Even this code shows two rows but no data. What am i missing?
LessonGrid.ItemsSource =
new[] {new {Color = Colors.Yellow,StartTime = 12, Text="text"},
new {Color = Colors.Red, StartTime = 14, Text="text3"}};
xaml:
<data:DataGrid x:Name="LessonGrid" AutoGenerateColumns="True" Height="375" IsReadOnly="True"> </data:DataGrid>