Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
DataGrid binding query in Xamarin
posted

I want to configure this type of table.
If more data comes in, one more column of C5 is created.

I want to bind it.
I need to set the PropertyPath in the column, but I don't know how to use it in the case of an array.

Column Wavelength = GridUtil.Instance.SetColumn(ColumnTypes.Text, "Wavelst", "Wavelength", new ColumnWidth() { Value = 150 });
this.xDataGrid.Columns.Add(Wavelength);
Column ABS = GridUtil.Instance.SetColumn(ColumnTypes.Text, "ABSlst", "C1", new ColumnWidth() { Value = 150 });
this.xDataGrid.Columns.Add(ABS);

List<ModelMeasureData> temp = new List<ModelMeasureData>();
foreach (var wave in this.m_Model.WaveList)
{
ModelMeasureData t = new ModelMeasureData();
t.Wavelst.Add(wave);
t.ABSlst.Add(wave);

temp.Add(t);
}

this.xDataGrid.ItemsSource = temp;

public class ModelMeasureData
{
public ModelMeasureData()
{
Wavelst = new List<float>();
ABSlst = new List<float>();
}

public List<float> Wavelst
{ get; set; }

public List<float> ABSlst
{ get; set; }

public float Wave { get; set; }
public float ABS { get; set; }


}

Parents
No Data
Reply
  • 34430
    Verified Answer
    Offline posted

    Hello,

    I have been investigating into the behavior you are looking to achieve in this case, and I can say currently that the data structure that you currently have set up will not work to achieve the visualization you are looking to achieve. Each column in the Infragistics for Xamarin needs to be pointed at a property on the underlying data item to a Row – in this case your “ModelMeasureData” object. Each ModelMeasureData will be a new row in the grid, and each property a potential column in the grid. If you try binding to Wavelst of ABSlst on one of the columns, it will only be a value of a single cell in the row representing that ModelMeasureData.

    Being that you are trying to do dynamic columns, I would recommend using a data structure that allows this such as a DataTable. In the DataTable, each Row would be a row in the grid, and each Column would be a potential Column in the grid.

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

Children
No Data