I started to work with WPF's datagrid and faced with the problem. I have such list
private List<ChainCode> _chainCode = new List<ChainCode>();
where ChainCode is:
public class ChainCode
{
private uint _number;
private byte _code;
public uint Number { get { return _number; } set { _number = value; } }
public byte Code { get { return _code; } set { _number = value; } }
}
So, I want to bind id to such DataGrid:
<DataGrid x:Name="dataGridChainCode" ItemsSource="{Binding _chainCode}" CanUserAddRows="True" IsEnabled="False" AutoGenerateColumns="False" Margin="10,35,18,0" VerticalAlignment="Top">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Number}" IsReadOnly="True" Header="#" Width="60"/>
<DataGridTextColumn Binding="{Binding Code}" Header="code" Width="60"/>
</DataGrid.Columns>
</DataGrid>
but when I launch my program, I can't add any row to datagrid, cuz there is no row, only headers. And I just have no idea how to fix it.
Update: I made such changes:
private ObservableCollection<ChainCode> _chainCode = new ObservableCollection<ChainCode>();
public ObservableCollection<ChainCode> OCChainCode { get { return _chainCode; } set { _chainCode = value; } }
and next in xaml:
ItemsSource="{Binding OCChainCode}"
but there is no response. What I doing wrong?
The one thing i understood is than it's too early for me to use WPF. So, I'll try to fix it later