.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

WPF Bindinggroup

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :WPF


I have a grid with a listview. I need to validate the rows to check for duplicate values. The user can add/delete rows from the listview. I am using bindinggroup to check that there are no duplicate values across the rows. This works fine except when I delete a row. Deleting a row from the listview does not remove the item from bindinggroup items list. Since the binding group items list still contains the deleted items, the validation continues to validate the deleted items. As a result the user ends up getting invalid messages. Why does the bindinggroup hold on to the the deleted items. Is there a way to prevent validation on the items removed from the listview?





View Complete Post

More Related Resource Links

Form Validation, BindingGroup, CommandBinding, Disabling Commit Button

Hi, I've been struggling with this for a few days and I couldn't get a clear and simple answer anywhere. Now that I've fixed the problem on my end, I figured I would share. The approach is about disabling a "Commit" button (Save/Apply/OK/whatever) whenever an error exists in the form. Basically, I have a form with several different controls (textbox, combobox, checkbox to name a few). All of them are bound to a custom object within my code, that I referenced using "RootGrid.DataContext = myObjectInstance". They also use BindingValidationRules, so the user is warned that they have wrong data in there. There's plenty of information about how to achieve this on the internet - but the real question mark is: how can I disable a button if there are errors in the form? First, go ahead and make those control validations work. For example, write a ValidationRule for a textbox to make sure it's only numbers in there, and then another ValidationRule for another textbox that ensures no digits are contained. Once again, google is full of examples on how to achieve this. Then, you need to group all of those controls into a BindingGroup. Before doing so, we will design a ValidationRule that will ensure the BindingGroup is free of validation errors:   public class ErrorFreeBindingGroup : ValidationRule { private string _errorMessage; public str

Validate Binding that is part of a BindingGroup on LostFocus without updating source


By default, when you tab out of a TextBox whose Text property is data bound, the value is pushed to the data source.  Data validation occurs as part of this process.

When you create a BindingGroup and the Binding becomes part of this BindingGroup, the value is no longer pushed to the data source when the TextBox loses focus.  This is what I want.  However, the data validation no longer occurs.  This is not what I want.

How do I validate a binding that is part of a BindingGroup on LostFocus without updating the source?  I want my users to have immediate feedback of data entry errors but I want to retain control over when data is pushed to the data source.

It would be great if this could be implemented as a style in a Theme.xaml file or any other solution that would not require hooking up to each and every LostFocus event handler in my application.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend