Home Forums WPF controls Xceed DataGrid for WPF How to set the row to the IsBeingEdited state in c# ?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24639 |

    How to set the row to the IsBeingEdited state in c# ?

    I have a probelm with that, I am explaining details. I have CustomDatagrid, which dervies from Xceed DataGrid for WPF, i have CustomDataCell and CustomDataRow as well. I have two categories of custom controls: for reading (StringControl – derives from TextBox) and editing (StringEditControl which derives from StringControl).

    I create custom controls for reading in that way:

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
    DataTemplate dt = null;

    if (item is String)
    {
    CreateCellEditor(typeof(String));

    dt = new DataTemplate();
    FrameworkElementFactory fef = new FrameworkElementFactory(typeof(StringControl));

    dt.VisualTree = fef;

    dt.DataType = typeof(Common.Data.StringDataField);
    CellEditorBindingExtension myCellEditorBinding = new CellEditorBindingExtension();
    dt.VisualTree.SetBinding(StringControl.TextProperty, (BindingBase)myCellEditorBinding.ProvideValue(null));
    return dt;
    }
    }

    In CreateCellEditor(typeof(String)) I create customCellEditors, which are my CustomEditControls:

    private void CreateCellEditor(Type __type)
    {
    Column.CellEditor = new CellEditor();
    Column.CellEditor.EditTemplate = new DataTemplate();
    CellEditorBindingExtension myCellEditorBinding = new CellEditorBindingExtension();
    Column.CellEditorDisplayConditions = CellEditorDisplayConditions.RowIsCurrent;
    Column.CellEditor.EditTemplate.VisualTree = new FrameworkElementFactory(typeof(StringEditControl));
    Column.CellEditor.EditTemplate.DataType = typeof(Common.Data.StringDataField); Column.CellEditor.EditTemplate.VisualTree.SetBinding(StringEditControl.TextProperty, (BindingBase)myCellEditorBinding.ProvideValue(null));

    }

    Now i would like to add this functionality:
    On keyboard focus or on mouce click i would like to change displaying from StringControl to StringEditControl, which can achieved by setting in CustomDataRow IsBeingEdited = true, i think so.. but this property is readonly.

    When i use default DataCells instead StringControls, one click works, but i would like to get by using my own controls.

    I would be grateful for any tip!

    Cheers
    Michael

    Imported from legacy forums. Posted by Michal (had 567 views)

    User (Old forums)
    Member
    Post count: 23064

    You should be able to call Cell.BeginEdit() or Row.BeginEdit() to make it enter into Edit mode. But actually if you want to automatic edit mode, you can set EditTriggers to CellIsCurrent.

    Imported from legacy forums. Posted by nat (had 234 views)

    User (Old forums)
    Member
    Post count: 23064

    EditTriggers – thanks for that!

    Michael

    Imported from legacy forums. Posted by Michal (had 3316 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.