Столкнулся с проблемой DataGrid не выводит содержимое поля .
XAML
<DataGrid x:Name="Jobs" Grid.Column="0" AutoGenerateColumns="False" ItemsSource="{Binding Path = Jobs}">
<DataGrid.Columns >
<DataGridTextColumn Binding="{Binding Path = Name}" Header="Job" Width="200*" IsReadOnly="False"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
ViewModel
class MainViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string prop = "")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
public List<Job> Jobs;
public MainViewModel()
{
Jobs = new List<Job>() { new Job() { Name = "sdfs" } ,
new Job() { Name = "sdytrfs" }};
}
}
И сам класс
Job
class Job : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string prop = "")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
public string Name
{
get { return name; }
set
{
name = value;
OnPropertyChanged("Name");
}
}
private string name;
List<JobTitle> jobs;
}