Home Forums WPF controls Xceed DataGrid for WPF SetCurrent cannot be invoked while another SetCurrent is in

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

    I am trying to implement a wrapper around the WPF DataGrid and providing mechanisms for custom validation. I capture the propertychanged event and fire my own custom event when “CurrentItem” is the property changed. If I receive a result from the validation event that the data is invalid I try to set the CurrentItem of the datagrid back to the original DataRow. When I do this, however, I receive the following error: “SetCurrent cannot be invoked while another SetCurrent is in progress.”. Is there a mechanism to get around this problem. This exception is raised on the line of code setting the CurrentItem of the datagrid

    ….
    System.Data.DataRow dr = (System.Data.DataRow)dataGrid.Items[RowIndex];
    dataGrid.BringItemIntoView(dr);
    dataGrid.SelectedItems.Clear();
    dataGrid.SelectedItems.Add(dr);
    dataGrid.CurrentItem = dr; <—- Error occurs here.
    …..

    Imported from legacy forums. Posted by Phil (had 2112 views)

    User (Old forums)
    Member
    Post count: 23064

    You have to use Dispatcher.BeginInvoke to set CurrentItem after your job is then.

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

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