DataGrid display is empty MVVM Wpf

Viewed 794

The problem: the DataGrid display is empty, however I have infos, and my DataGrid received the information but still empty!

My XAML:

<DataGrid x:Name="dataGrid" Grid.Row="1" ItemsSource="{Binding ViewList}" 
          CanUserAddRows="False" AlternationCount="2"
          AlternatingRowBackground="Blue">
  <DataGrid.Columns>
    <DataGridTextColumn Header="View" Binding="{Binding id}"
                        Width="2*" IsReadOnly="True" />
    <DataGridTemplateColumn Header="Is Enabled" Width="Auto">
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <CheckBox IsChecked="{Binding isEnabled, Mode=TwoWay,
                        UpdateSourceTrigger=PropertyChanged}"/>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>                
  </DataGrid.Columns>
</DataGrid>

My ViewModel:

public ConfigRoleModel()
{
    _viewList = new ObservableCollection<ViewList>(WCFclient.getListOfViews(1));
}

private ObservableCollection<ViewList> _viewList;
public ObservableCollection<ViewList> ViewList
{
    get { return _viewList; }
    set
    {
        _viewList = value;
        OnPropertyChanged("ViewList");
    }
}  

ViewList class:

public class ViewList
{
    public int id;    
    public string description;
    public string code;
}

This is the result:enter image description here

How can I fix it ?

3 Answers
Related