我不得不改动我的xaml/代码,以便使该编码对<编码>properties =>学校课堂Name和deonName的工作对TextBlock
具有约束力? 我没有错觉,但我看不到所显示的任何东西:
<Grid Margin="20" Height="300" Background="AliceBlue">
<ListView ItemsSource="{Binding Timetable}">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Period"
DisplayMemberBinding="{Binding LessonPeriod}"/>
<GridViewColumn Header="Monday">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListView ItemsSource="{Binding Monday}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Width="150" Orientation="Horizontal">
<TextBlock Text="{Binding LessonName}"/>
<TextBlock Text=" "/>
<TextBlock Text="{Binding SchoolclassName}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Grid>
public partial class Window1 : Window
{
List<TimetableEntry> _timetable = new List<TimetableEntry>();
public List<TimetableEntry> Timetable
{
get { return _timetable; }
set { _timetable = value; }
public Window1()
{
InitializeComponent();
_timetable.Add(new TimetableEntry()
{
LessonPeriod = "Period 1",
Monday = new TimetableDay()
{
LessonName = "Maths" ,
SchoolclassName = "1c",
},
}
);
this.DataContext = this;
}
public class TimetableEntry
{
public string LessonPeriod { get; set; }
public TimetableDay Monday { get; set; }
public TimetableDay Tuesday { get; set; }
public TimetableDay Wednesday { get; set; }
public TimetableDay Thursday { get; set; }
public TimetableDay Friday { get; set; }
public TimetableDay Saturday { get; set; }
public TimetableDay Sunday { get; set; }
}
public class TimetableDay
{
public string LessonName { get; set; }
public string SchoolclassName { get; set; }
}
public class TimetableLesson
{
public string LessonName { get; set; }
public string SchoolclassName { get; set; }
public DateTime LessonTime { get; set; }
}
}