I want bind property of model to datagrid, i can't do it I have property in model model contains list with list of strings rows count is constant in list
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public class TestViewModel : ViewModelBase
{
public TestViewModel()
: this(new FileService())
{
}
public TestViewModel(IFileService fileService)
{
var list = new List<List<string>>();
list.Add(new List<string>() { "1", "2", "3" });
list.Add(new List<string>() { "3", "4", "5" });
RecodListFromCsv = list;
}
private List<List<string>> _RecodListFromCsv;
public List<List<string>> RecodListFromCsv
{
get { return _RecodListFromCsv; }
set
{
if (_RecodListFromCsv != value)
{
_RecodListFromCsv = value;
OnPropertyChanged("RecodListFromCsv");
}
}
}
}
xaml
<Window x:Class="Test.Views.TestView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModel="clr-namespace:Test.ViewsModel"
Title="PriceList" Height="427" Width="746">
<Window.Resources>
<viewModel:TestViewModelx:Key="TM" />
</Window.Resources>
<DockPanel LastChildFill="True" DataContext="{Binding Source={StaticResource TM}}">
<DataGrid AutoGenerateColumns="True" ItemsSource="{Binding RecodListFromCsv}">
</DataGrid>
</Menu>
</DockPanel>
</Window>
and UI show

What I'm doing wrong. how to do it?