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
1285
How to create FieldLayout and Fields in Code behind(C#)
posted

Hi,

I want to create XamDataGrid,FieldLayout and Fields in code behind instead of Xaml.

In my Xaml file should be like this:

=========================

<Grid Name="grid">

</Grid>

=========================

Code behind :

public void Load()
{
x1 = new XamDataGrid();

FieldLayout fl = new FieldLayout();

//FieldLayout F1 = new FieldLayout();


//Field fieldA = new Field();
//Field fieldB = new Field();

//fieldA.Label = "FieldA";
//fieldB.Label = "FieldB";

Infragistics.Windows.DataPresenter.Field field = new Infragistics.Windows.DataPresenter.Field();

//RowDefinition row = new RowDefinition();

field.Name = "CSP";
field.Label = "Chandra";

fl.Fields.Add(field);

x1.FieldLayouts.Add(fl);

// x1.FieldLayoutInitialized += new EventHandler<Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs>(x1_FieldLayoutInitialized);

this.grid.Children.Add(x1);
}

I am calling load method from Constructor..

In my case, xamDatagrid with Column "Chandra" should come..but it is not coming..

Please let me know, where i did mistake..

Please help me..

Parents
  • 35319
    Verified Answer
    posted

    Hello,

     

    Thank you for your post. I have created a sample application(DataGridFieldsCodeBehind.zip) here I am adding the fields in the XamDataGrid in code-behind. If this is not your scenario, please modify my sample application in order to provide you with more accurate assistance.

     

    Looking forward to hearing from you.

     

    DataGridFieldsCodeBehind.zip
Reply Children