내가 놓친 게 분명하다는 것을 알고 있습니다. 데이터 서비스를 사용하여 Silverlight 응용 프로그램에 데이터를 가져옵니다. 난 내 데이터 그리드에 데이터를 바인딩 할 때 그것은Silverlight에서 복잡한 객체에 바인딩하기
LessonGrid.ItemsSource = context.Lessons
그러나 곧 내가 그것을 내가 바인딩을 정의하기 위해 노력
LessonGrid.ItemsSource = context.Lessons.Select(l => new {Lesson = l; Color=Colors.Yellow})
작동을 멈 춥니 다 더 복잡한 데이터 구조로 내 개체를 래핑하는 시도로 매력처럼 작동 길을 잃어 버렸고 작동하지 않는 것처럼 보입니다.
<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}"/>
제안 사항? 더 많은 연구 후
:
좋아, 그것은 복잡한 객체와는 아무 상관 없습니다. 이 코드조차도 두 행을 표시하지만 데이터는 표시하지 않습니다. 나는 무엇을 놓치고 있습니까?
LessonGrid.ItemsSource =
new[] {new {Color = Colors.Yellow,StartTime = 12, Text="text"},
new {Color = Colors.Red, StartTime = 14, Text="text3"}};
XAML : 당신은 Linq에 쿼리를 작성했지만 실제로는 아직 실행되지 않은
<data:DataGrid x:Name="LessonGrid" AutoGenerateColumns="True" Height="375" IsReadOnly="True"> </data:DataGrid>
명확히하기 위해 StartTime은 Lesson 객체의 속성입니다. – Vitalik