none
DataGrid gets locked on ValidationError RRS feed

  • Question

  • Hi,

     I am using a simple a ValidationRule on DatagridTextColumn. The Validation occurs properly so no issues there. If ValidationError occurs, then the whole DataGrid is locked (and that seems reasonable). The problem occurs when the row for which validation failed is removed from the DataGrid. The row in error gets removed, but somehow the other DataGrid rows still remains in a Locked(non editable) state even if there aren't any more rows failing the validation. Any ideas why DataGrid rows still remain locked. Here is relevant code for the DataGridTextColumn.

            <DataGridTextColumn 
              <DataGridTextColumn.Binding>
                <Binding Path="Name" NotifyOnValidationError="True"
                     UpdateSourceTrigger="LostFocus">
                  <Binding.ValidationRules>
                    <local:SomeValidationRule/>
                  </Binding.ValidationRules>
                </Binding>
              </DataGridTextColumn.Binding>
            </DataGridTextColumn>
    


    regards,

    Nirvan.

     

    Saturday, June 11, 2011 7:34 AM

Answers

  • Hi Nirvan,

    Thank you for your feedback!

    I can reproduce the issue and I have to admit that the behavior is less desirable. Currently our developers are aware of this issue already. They will take this into serious account when designing the future releases of the products.

    You can also post the suggestions to our Connect feedback portal. Our developer will evaluate them seriously and take them into consideration when designing future release of the product.

    https://connect.microsoft.com/WPF

    Improving the quality of the products and services is a never-ending process for Microsoft. Thanks again for choosing us.

    Best regards


    Yves Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Nirvan Sunday, June 19, 2011 6:44 AM
    Friday, June 17, 2011 5:27 AM
    Moderator

All replies

  • Hi,

    this might not be very helpful, but as far as I have tested the DataGrid, it seems to have a number of different problems with editing data, so I would recommend that you use a different design. E.g. you could use the DataGrid to display and select data, and a detail view next to it to edit the rows.

    How does focus behave in your application? When I tried adding a new row after finishing editing a previously added new row, the focus never went from the added row to the next added row, but jumped up to the beginning of the list... didn't get around it and decided to use a ListView in GridView mode instead.


    http://wpfglue.wordpress.com
    Sunday, June 12, 2011 2:09 PM
  • hbarck,

         Surely, it would not be simple to use DataGrid out of box for editing operations. I was just experimenting with it to know about its feasiblity and the extent of customization that it might require. But I have realized that it is far more easier to use, than corresponding control in other languages, particularly its binding features.

         For the second part of your response, I stumbled upon the same problem, but resolved it after some study and help from web. Here is the link in which I had posted the issue http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/cee0fefc-0971-4619-8214-8937558f4e78  

         I still feel that datagrid may provide better experience to user than using the SelectedItem method. But I still am evaluating the cost of customization at this stage. If you resolve the issue mentioned in this thread, please post the solution. 

    Thanks for the suggestions.

    regards,

    Nirvan. 

    Sunday, June 12, 2011 5:34 PM
  • I shifted to row level validation instead of cell level validation in the hope of clearing ValidationError when an invalid row is deleted (and row validation also suits to my requirements). Strangely, even if the entire row that has validation error is deleted, the DataGrid still remains in un-editable (locked) mode. I am confused now as to how to delete invalid rows in the datagrid. Here is the relevant code that I am using.

    //My xaml file 
    
    
    <DataGrid Name="productList" 
            ItemsSource="{Binding Path=CurrentCategory.Products}"
             KeyboardNavigation.TabNavigation="Contained"
             RowEditEnding="productList_RowEditEnding">
    <DataGrid.RowValidationRules>
            <local:UniqueValidationRule ValidationStep="UpdatedValue" 
             view="{StaticResource prodList}"/>          
     
    ........
    
    
    //My Code Behind file (deleting row handler)
    
    private void btnRemove_Click(object sender, RoutedEventArgs e) {
        Product product = ((FrameworkElement)sender).DataContext as Product;
          
          if (product != null) {
            CurrentCategory.Products.Remove(product);
          }
    }
    

    If anyone has any suggestions as to how to unlock DataGrid after an Invalid Row (as marked by ValidationRule) is deleted.

    regards,

    Nirvan.

     

    Tuesday, June 14, 2011 2:37 PM
  • Hi Nirvan,

    Thank you for your feedback!

    I can reproduce the issue and I have to admit that the behavior is less desirable. Currently our developers are aware of this issue already. They will take this into serious account when designing the future releases of the products.

    You can also post the suggestions to our Connect feedback portal. Our developer will evaluate them seriously and take them into consideration when designing future release of the product.

    https://connect.microsoft.com/WPF

    Improving the quality of the products and services is a never-ending process for Microsoft. Thanks again for choosing us.

    Best regards


    Yves Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Nirvan Sunday, June 19, 2011 6:44 AM
    Friday, June 17, 2011 5:27 AM
    Moderator
  • Zhang,

            Thanks for taking up the issue. I will leave this thread open (unanswered) for a day or two, in case anyone has possible workarounds. 

    regards,

    Nirvan.

    Friday, June 17, 2011 6:11 AM
  • Has this been fixed yet?
    Monday, January 14, 2013 6:30 PM
  • I get a similar problem in my DataGrid using WPF.

    I found the issue easier to replicate if I get the row in a validation error state, then go to another row, then back to the row, then to another TAB. When I go back to the previous tab, the DataGrid is kind of locked and cannot edit anymore. I don't disable it. And it still processes arrow keys, but refuses to go into edit mode. BeginEdit() fails but CommitEdit() returns true if I try to play with it in my code.

    I am clueless as to what to try next. Please help.


    • Edited by Martin Lottering Friday, July 26, 2013 11:05 AM Wrong platform specified
    Friday, July 26, 2013 10:34 AM
  • I have exact same problem as you mentioned. Is there any solution for this problem?
    Tuesday, July 29, 2014 1:12 PM