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
135
XamDataGrid add new column and fill from array on fly
posted

I am trying to add new column to xamdatagrid on fly. I am getting the column anseright but I can't fill it. 

Can someone show me what I am doing wrong.

Here is xml

  <igDP:XamDataGrid  DataSource="{Binding Path=Container.Columns}" GroupByAreaLocation="None" 
                            FieldLayoutInitialized="xamDataGrid_FieldLayoutInitialized"
                         >

            <igDP:XamDataGrid.FieldLayoutSettings>
                <igDP:FieldLayoutSettings AutoGenerateFields="False"
                                        AutoFitMode="Always" 
                                        AllowAddNew="False"

                                          
                                          />

            </igDP:XamDataGrid.FieldLayoutSettings>
            </igDP:XamDataGrid>

C# code

 public partial class SpreadsheetView : Window
    {
        public SpreadsheetView()
        {
            InitializeComponent();
        }

        public SpreadsheetViewModel ViewModel
        {
            get { return this.DataContext as SpreadsheetViewModel; }
        }

        void xamDataGrid_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
        {
            List<ISimulatedValue> container = this.ViewModel.Container.Columns;

            

            for (int i = 0; i < container.Count; i++)
            {
                var field = new UnboundField
                {
                    Name = container[i].Name,
                    BindingMode = BindingMode.TwoWay,
                    BindingPath = new PropertyPath(String.Format("{0}[{1}]", nameof(ISimulatedValue.AllValues), i)),
                    AllowEdit = false,
                    Format = "P2"


                };

                field.Settings.EditAsType = typeof(String);
                e.FieldLayout.Fields.Add(field);


            }



        }


    }

 

I got the colum names right, but I can't fill them.

ISimulatedValues.AllValues returns double array