Как забиндить компаненты в DataGrid?
Есть такой DataGrid
<DataGrid Grid.Row="1" x:Name="DGStudents" Margin="10" IsReadOnly="True"
AutoGenerateColumns="False" ItemsSource="{Binding Path=studends}">
<DataGrid.Columns>
<DataGridTextColumn Header="Студент" Width="*" Binding="{Binding Path=FullName}"/>
<DataGridTextColumn Header="Группа" Width="*" Binding="{Binding Path=Group}"/>
<DataGridTextColumn Header="Курс" Width="*" Binding="{Binding Path=Course}"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.75*"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" ItemsSource="{Binding Path=Exams}"
DisplayMemberPath="Name" IsEnabled="True">
</ComboBox>
<Grid Grid.Column="1">
<Grid.DataContext>
<view:OrganaizerManagerVeiwModel/>
</Grid.DataContext>
<TextBlock Text="{Binding Path=Description_of_student}"/>
</Grid>
</Grid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
Классы для биндинга
internal class Student: PropertyChanging
{
public string FullName { get; set; }
public string Group { get; set; }
public int Course { get; set; }
public List<Exam> Exams { get; set; }
public Student(string fullname, string group, int course)
{
FullName = fullname;
Group = group;
Course = course;
}
}
internal class Exam
{
public string Name { get; set; }
public string Description { get; set; }
public Exam(string name, string decr)
{
Name = name;
Description = decr;
}
public override string ToString()
{
return Description;
}
}
Коллекция, которая забиндена к DataGrid
public ObservableCollection<Student> studends { get; set; }
= new ObservableCollection<Student>()
{
new Student("Ivan Petrov", "21-KB-PR2", 2)
{Exams = new List<Exam>()
{
new Exam("Math", "Perfect"),
new Exam("OOP", "Good"),
new Exam("TRPO", "Bad")
}
}
};
Вопрос. Как можно забиндить два свойства SelectedItem и Description_of_student
Сами свойства:
private Exam _selected_item;
public Exam SelectedItem
{
get => _selected_item;
set { Set(ref _selected_item, value);
MessageBox.Show(_selected_item.ToString()); }
}
private string description_of_student;
public string Descruption_of_student
{
get => description_of_student;
set => Set(ref description_of_student, value);
}
При попытке забиндить через Path у меня отображаются свойства класса Student