Hello,
what do I have to change in my xaml/code to make the binding to the properties => SchoolclassName and LessonName work on both TextBlocks? I get no Binding errors but I do not see anything displayed?
<Grid Margin="20" Height="300" Background="AliceBlue">
<ListView ItemsSource="{Binding Timetable}">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Period" DisplayMemberBinding="{Binding LessonPeriod}"></GridViewColumn>
<GridViewColumn Header="Monday">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListView ItemsSource="{Binding Monday}" >
<ListView.ItemTemplate >
<DataTemplate>
<StackPanel Width="150" Orientation="Horizontal">
<TextBlock Text="{Binding LessonName}"></TextBlock>
<TextBlock Text=" " />
<TextBlock Text="{Binding SchoolclassName}"></TextBlock>
</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; }
}
}