Home Forums WPF controls Xceed DataGrid for WPF PropertyChanged for CellEditorBinding

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

    Hello I have the following CellEditorTemplate, I’m using the template for most of my cells and it works well. However, I want the changes to register as the user is typing the cell, not after the cell has lost focus.

    <xcdg:CellEditor x:Key=”txtBoxEditor”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <TextBox Text=”{xcdg:CellEditorBinding}”/>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    How should I apporach this problem. I wanted to use PropertyChanged but I don’t know how it fits into this template.

    Thanks

    Imported from legacy forums. Posted by Murthy (had 944 views)

    User (Old forums)
    Member
    Post count: 23064

    Can anyone help with this? Your input is greatly appreciated.

    Thanks

    Imported from legacy forums. Posted by Murthy (had 558 views)

    Xceed Support
    Member
    Post count: 5658

    Could you explain why you would like the content to be updated immediately? Doing so will prevent changes from being rollbacked in the case where the inputted information is wrong.

    If you really want to do this (and I don’t recommend it) you could call EditEdit() followed by BeginEdit() after each key stroke. Performance wise, this may be a big hit though.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 224 views)

    User (Old forums)
    Member
    Post count: 23064

    >> If you really want to do this (and I don’t recommend it) you could call EditEdit() followed >> by BeginEdit() after each key stroke. Performance wise, this may be a big hit though.

    Did you mean “you could call EndEdit() followed ” ??

    Mmmm.. I went through this process as it was a specification requirement but couldn’t get the AutoSelectTextBox to trigger on the next Cell after hitting the Tab…

    Imported from legacy forums. Posted by Desmond (had 574 views)

    Xceed Support
    Member
    Post count: 5658

    Yes, I meant EndEdit().

    “but couldn’t get the AutoSelectTextBox to trigger on the next Cell after hitting the Tab… “

    I am not sure what you mean. Could you clarify?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 365 views)

    User (Old forums)
    Member
    Post count: 23064

    Certainly…

    If I do NOT have _Cell.EndEdit then after entering text in a Cell and pressing Tab the next field (to the right) is AutoSelected and the Cursor is in that Cell ready for typing data in.

    If I have a _Cell.EndEdit() then of course I have left editing mode so I would assume that the EditTrigger setting comes into play. So when I execute a _Cell.BeginEdit() I would expect the Edit Trigger to use the CellEditor with the AutoSelectTextBox.

    I have a settings of

    <pre>
    this.xaml_MainDetails_DataGridControl.EditTriggers = EditTriggers.CellIsCurrent | EditTriggers.SingleClick;
    this.xaml_MainDetails_DataGridControl.CellEditorDisplayConditions = CellEditorDisplayConditions.MouseOverCell;
    </pre>

    Basically, we would like to allow a fast user to type and use either {Tab} or {Enter} to move to the next field (including moving to the next row when either are hit on the last editable column). We also would like that of they are in the middle of entering 30 columns of numbers for example and they hit the {Save} button at the bottom then everything in that last editited row will be saved. I guess I may have surreptitiously answered my one question by’execute _Cell.EndEdit() after the Save button is hit..however..I would like to know what is going on here..please….

    Cheers,

    Dezzz.

    Cheers,

    Dezzz.

    Imported from legacy forums. Posted by Desmond (had 438 views)

    Xceed Support
    Member
    Post count: 5658

    I am currently experiencing the same behavior. I will keep you posted.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 399 views)

    User (Old forums)
    Member
    Post count: 23064

    Cheers….

    Imported from legacy forums. Posted by Desmond (had 416 views)

    Xceed Support
    Member
    Post count: 5658

    I handled the PreviewKeyDown on the DataGridControl and am handling the Enter and Tab keys. Pressing either navigates to the next cell or row (at the end) and the user can immediately input data.

    DISCLAIMER: This code is very hardcoded. You should make certain validations such as when there are no more next rows when the keys are pressed. Also, the VisiblePosition of the CurrentColumn should be used.

    <code>
    private void EnterKeyDown( object sender, KeyEventArgs e )
    {
    if( ( e.Key == Key.Enter ) || ( e.Key == Key.Tab ) )
    {
    int index = this.OrdersGrid.CurrentColumn.VisiblePosition;

    Xceed.Wpf.DataGrid.DataRow currentRow = this.OrdersGrid.GetContainerFromItem( this.OrdersGrid.CurrentItem ) as Xceed.Wpf.DataGrid.DataRow;

    if( index < currentRow.Cells.Count – 1 )
    {
    currentRow.Cells[ index + 1 ].BeginEdit();
    e.Handled = true;
    }
    else
    {
    int currentIndex = this.OrdersGrid.Items.IndexOf( this.OrdersGrid.CurrentItem );
    this.OrdersGrid.CurrentColumn = this.OrdersGrid.Columns[ 0 ];
    this.OrdersGrid.CurrentItem = this.OrdersGrid.Items[ currentIndex + 1 ];
    e.Handled = true;
    }
    }
    }
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 628 views)

    User (Old forums)
    Member
    Post count: 23064

    Nice piece of code Jenny…works a helluva lot better than all that Navigation stuff..

    Cheers,

    Dezzz.

    Imported from legacy forums. Posted by Desmond (had 6923 views)

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