locked
Populate ComboBox inside xamDataGrid RRS feed

  • Question

  • Hello,

    i have a xamDatagrid  (WPF)set up as follows :

    <igDP:XamDataGrid  DataSource="{Binding}"  x:Name="xamContact" >
      <igDP:XamDataGrid.FieldLayouts>
    <igDP:FieldLayout>
    <igDP:Field Name="DepartmentName" Label="Department Name" />
    <igDP:Field Name="FirstName" Width="100" Label="First Name" />
     <igDP:Field Name="LastName" Label="Last Name" />
     <igDP:Field Name="RoleName" Label="Role Name" />
     <igDP:ComboBoxField Name="Contactby" Visibility="Visible" ItemsSource="{Binding}"  Label="Contactby"></igDP:ComboBoxField>
     <igDP:Field  Name="ContactType" Label="ContactType" Visibility="Collapsed" />
      </igDP:FieldLayout>   
     </igDP:XamDataGrid.FieldLayouts>
    </igDP:XamDataGrid>

    in the code behind i want populate the xamDataGrid included the ComboBox field"Contactby"(situated in the xamDataGrid) as follows:

    public DataTable GetContTable()
        {
    
            DataTable tableCont = new DataTable();
            tableCont.Columns.Add("DepartmentName", typeof(string));
            tableCont.Columns.Add("FirstName", typeof(string));
            tableCont.Columns.Add("LastName", typeof(string));
            tableCont.Columns.Add("RoleName", typeof(string));
            tableCont.Columns.Add("Contactby", typeof(object));
            tableCont.Columns.Add("ContactType", typeof(string));
          tableCont.Columns[5].ColumnMapping = MappingType.Hidden;
        
            return tableCont;
        }
    
          public void AddRowsCont(DataTable dtcont)
        {
     string[] card = new string[1000];
            for (int i = 0; i < lstContactBy.Items.Count; i++)// in this listbox the number of string is dinamic  then can change number of items each time need insert a new record in the xamdatagrid
            {
                card[i] = lstContactBy.Items[i].ToString();
            }
            dtcont.Rows.Add(txtDepartment.Text, txtFirstName.Text, txtlastName.Text, txtROlename.Text,card  ,"SKYPE"); 
    
        }
    
        //here is the button to insert the data in the xamdatagrid
    
        AddRowsCont(tableCont);
        xamContact.DataSource = tableCont.DefaultView;

    the result is the xamdatagrid can be populate instead the ComboBox "Contactby" is populate only with a message'String[] Array' How i can populate the ComboBox with items without any errors?

    Thanks

    Jay


    • Moved by Xavier Xie-MSFT Wednesday, September 2, 2015 2:01 AM third-party
    Wednesday, August 26, 2015 12:44 PM

All replies

  • xamDataGrid is a third-party control from Infragistics: http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/xamDataGrid.html

    Please don't ask any questions about third-party software in these forums as they are intended for Microsoft's products and technologies only.

    If you have any questions or issues regarding Infragistics's products you should ask in their own forum: http://www.infragistics.com/community/forums/

    Thanks for your understanding.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread in an appropriate forum if you have a new question. Please don't ask several questions in the same thread.

    • Proposed as answer by messizhu Thursday, August 27, 2015 2:59 AM
    Wednesday, August 26, 2015 12:47 PM
  • I have no idea how a xamdatagrid works or a comboboxfield in one.

    You seem to be binding the itemssource of the combo to whatever is in the row.

    <igDP:ComboBoxField Name="Contactby" Visibility="Visible" ItemsSource="{Binding}"  Label="Contactby"></igDP:ComboBoxField>
    

    That seems unlikely to be right.

    This article describes how to bind a datagridcomboboxcolumn in a wpf datagrid:

    http://social.technet.microsoft.com/wiki/contents/articles/26347.aspx

    Maybe you could change to use a regular datagrid or the comboboxfield works similarly enough you could adapt the approach.


    Wednesday, August 26, 2015 1:46 PM