Binding Cell Editing Template incorrect

Posted by: mr.wlight on 30 August 2018, 3:38 pm EST

    • Post Options:
    • Link

    Posted 30 August 2018, 3:38 pm EST

    Hi,

    I follow this topic https://www.grapecity.com/en/forums/wpf-edition/cell-contents-are-changed- but i have trouble when i binding CellEditingTemplate.

    When i click to changed Cell to Cell Edit, data grid not call BindCellContent method , that reason why cell not have content although binding applied.

    http://www.mediafire.com/view/jzbi35bjjbmr57r/Mainwindow.JPG

    http://www.mediafire.com/file/xbhgo48kvmtmyza/output.JPG/file

    I was hotfix this bug and i comment in attached project. I think this is a bug of C1DataGrid.

  • Posted 30 August 2018, 4:05 pm EST

  • Posted 2 September 2018, 8:09 pm EST

    Hello,

    I am able to see what you are mentioning. However, this and some other binding errors might be shown while C1DataGrid builds its UI. While UI is not complete yet, some bindings can’t be resolved properly. But as far as control works, you can be sure that these bindings finally got resolved. So, this is by design but would not harm your application, hence can safely ignore these warning message.

    Now, to show the value of ValueAsString in cell-edit control, apart from your HotFix/workaround, I would suggest you to override PrepareCellForEdit and GetCellEditingContent methods as follows:

            public DataGridRow RowEditing { get; set; }
            public override object PrepareCellForEdit(FrameworkElement editingElement)
            {
                Binding newBinding = Binding.Clone();
                newBinding.Source = RowEditing.DataItem;
                editingElement.SetBinding(FrameworkElement.DataContextProperty, newBinding);
                return base.PrepareCellForEdit(editingElement);
            }
            public override FrameworkElement GetCellEditingContent(DataGridRow row)
            {
                RowEditing = row;
                return base.GetCellEditingContent(row);
            }
    

    Also, attached is modified application for reference.

    Thanks,

    Ruchir

    DataGridCreateColsInCodeBehind_Fixed.zip

  • Posted 3 September 2018, 1:09 pm EST

    Same way fix cell content,

    Thanks Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels