In my DataGrid I have three columns, number of rows is dynamic. The values for the DataGrid are double arrays. How can I bind each array to his column without creating a new class (I've propertychangedevent on each array)
<DataGrid Name="dataGrid" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Style="{DynamicResource DataGridStyle1}"
CellEditEnding="dataGrid_Kennlinie_CellEditEnding" BeginningEdit="dataGrid_Kennlinie_BeginningEdit"
MaxWidth="500">
<DataGrid.Columns>
<DataGridTextColumn Header="nue" Binding="{Binding nue}" Width="*">
<DataGridTextColumn.Foreground>
<SolidColorBrush Color="Black"/>
</DataGridTextColumn.Foreground>
</DataGridTextColumn>
<DataGridTextColumn Header="mue" Binding="{Binding mue}" Width="*"/>
<DataGridTextColumn Header="tpc[Nm]" Binding="{Binding MPc}" Width="*" />
....end
nue, mue and MPc are arrays inbetween another class. When I just do
dataGrid.ItemSource = class.nue;
In this class I create the class which includes my needed variables, these are:
private double[] _nue;
public double[] nue
{
get { return _nue; }
set
{
if (_nue == value) return;
_nue = value;
OnPropertyChanged("_nue");
}
}
private double[] _mue;
public double[] mue
{
get { return _mue; }
set
{
if (_mue == value) return;
_mue = value;
OnPropertyChanged("_mue");
}
}
private double[] _MPc;
public double[] MPc
{
get { return _MPc; }
set
{
if (_MPc == value) return;
_MPc = value;
OnPropertyChanged("_MPc");
}
}
it sets me the correct number of rows but without values.
Any ideas? Thanks and happy new year