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
265
XamGrid bidning to Collection/Lists
posted

I was expecting this to be fairly straightforward but not sure what's wrong. I am using version 10.2.20102.2005. Here is my sample code

XAML:

<ig:XamGrid x:Name="igGrid" AutoGenerateColumns="False" Height="150">
                <ig:XamGrid.Columns>
                    <ig:TextColumn Key="WorksheetID" HeaderText="Worksheet Id"/>
                    <ig:TextColumn Key="LineItemID" HeaderText="LineItem Id"/>
                    <ig:TextColumn Key="GOID" HeaderText="GOID"/>
                    </ig:XamGrid.Columns>

</ig:XamGrid>

 

C# code:

public void FetchMyWorkSheets()
        {
            List<Worksheet> worksheets = new List<Worksheet>();
            for (int i = 0; i < 10; i++)
            {
                Worksheet ws = new MyWorksheet();
                ws.WorksheetID = i;
                ws.LineItemtID = i * i;
                ws.GOID = i + i;

                worksheets.Add(ws);
            }

            igGrid.ItemsSource = worksheets;
        }

 

public class Worksheet
    {
        public int WorksheetID { get; set; }
        public int LineItemtID { get; set; }
        public int GOID { get; set; }
    }

 

Exception:

Following exception is thrown at line igGrid.ItemsSource = worksheets;

Infragistics.Controls.Grids.InvalidColumnKeyException was unhandled by user code
  Message=The following key(s) do not correspond with the DataSource: "LineItemID". If you'd like to add additional columns, please use the UnboundColumn type.
  StackTrace:
       at Infragistics.Controls.Grids.RowsManager.InitializeData()
       at Infragistics.Controls.Grids.RowsManager.SetupDataManager()
       at Infragistics.Controls.Grids.RowsManager.EnsureDataManager()
       at Infragistics.Controls.Grids.RowsManager.OnItemsSourceChanged()
       at Infragistics.Controls.Grids.RowsManager.set_ItemsSource(IEnumerable value)
       at Infragistics.Controls.Grids.XamGrid.ApplyItemSource(IEnumerable itemSource)
       at Infragistics.Controls.Grids.XamGrid.ItemsSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Infragistics.Controls.Grids.XamGrid.set_ItemsSource(IEnumerable value)
       at Jenzabar.EX.SLTestPage.FetchMyWorkSheets()
       at Jenzabar.EX.SLTestPage.btnFetch_Click(Object sender, RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
  InnerException:

 

 

Parents
No Data
Reply Children