I am working on a project to use XamGrid to create an interface that will behave like an excel worksheet in many way. User should be able to add, remove, rearrange columns at run time and persist the resultant grid structure to a database. I am binding this grid to an ObserveableCollection<TemplateRow> where
public class TemplateRow { public ObservableCollection<string> Cells { get; set;} }
Logically this object seems ok but XamGrid renders it as hierarchical and I can see why it's doing that. Any ideas on how my Grid bindings or object structure should look like to accomplish this.
Hello,
This issue has been addressed and resolved in the next release v2009.1. It will be released in the beginning of April or the next hotfix in the mid of April
Alex.
I am attaching a sample VS 2008 project using XAMGrid that replicates the issue. In order reproduce this behavior
I don't see the issue with the latest internal version so I suspect this has already been addressed but I would recommend submitting the issue to the support group so it can be verified that the issue you are seeing is indeed addressed and so you can be notified when a hotfix is available.
Can anyone from Infragistics help explain why grid binding is throwing this exception. This appears to be a grid problem.
I made some progress based on previous hint. Here is what my code looks like
private void MenuItemAddTextColumn_Click(object sender, RoutedEventArgs e){ AddColumn(this, null); // delegate to presenter to add cells to observeable datasource
string colNum = templateXamGrid.FieldLayouts[0].Fields.Count.ToString(); //Play with XamGrid Layout to dynamically add field. UnboundField uf = new UnboundField(); uf.Name = "Cells[" + colNum + "]"; uf.Label = "Col " + colNum; PropertyPath p = new PropertyPath("Cells[" + colNum + "]"); uf.BindingPath = p; templateXamGrid.FieldLayouts[0].Fields.Add(uf); }
On XAML side I have set AutoGenerateFields=false. This seem to work fine. I can add columns and they all show up on same level. The problem comes if I rearrange columns in middle of adding new columns and then try to add another column. It throws an exception on following line
templateXamGrid.FieldLayouts[0].Fields.Add(uf);
The exeption says "The given key was not present in the dictionary."
Debugging through the code, I can see that AddColumn() did it's job to properly add new cell to each of exisiting rows (simulating column addition) but binding somehow is failing.