Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi
                                    I want to use validation of editors using MVVM.
                                    For example I have an TextEdit bound to a prop from LinqToSql class.
                                    I've bind it set ValidateOnDataErrors=true, UpdateSourceTrigger=tried all but it not validate it
                                    Any ideas ?

                                0

                                Hello Sorin,

                                Thank you for your question. I suggest that you try to use an approach suggested in our documentation: Error Notification . Does it meet your requirements?

                                Thank you, Marina

                                0

                                Hi again
                                I was trying not to use code behind with MVVM.
                                All I need it's just to validate when a TextEdit has a null EditValue.
                                I've attached some "code"
                                Thank's

                                Sample.txt
                                0

                                Hi Sorin,

                                You need to validate data in the view model to make this work. If you enabled the ValidatesOnDataErrors property, you need to make the data object an implementation of the IDataErrorInfo interface. Our TextEdit supports all standard validation approaches. Please take a look at the Data Binding MSDN article to learn more about validation.

                                Thanks,
                                Ted

                                0

                                Based on my actual pattern I think it's impossible to validate a new item before it's inserted

                                0

                                Hi Sorin,

                                When a user types anything in the editor, the typed data should pass validation. No matter which of the approaches you will use, if validation fails, the data will not be written to the object's property. Therefore, all validation is performed before the data is inserted. Are you experiencing any trouble implementing one of the validation ways? Which one you're trying to include in your data object?

                                Thanks,
                                Ted

                                0

                                Hi Ted
                                Thank you for your patience.
                                Please take a look at the sample text attached before.
                                I need to validate when a user clicks on update button first (after using add button which makes currentItem a new object)
                                Because I don't want to insert null values in the database.
                                So I need something to call validate at update button.
                                Thank's

                                Sorin

                                0

                                Hi Sorin,

                                The data object validation is performed as soon as the binding tries to update a value. Since you set the UpdateSourceTrigger property to the "LostFocus" value, validation will be performed as soon as the editor loses focus. After that, depending on how you implemented the validation mechanism, the value will be validated in the data object and if the validation is passed, the value will be assigned to the property.
                                There is no way to perform validation on demand in this case.
                                In the "UpdCommand" Execute method, you can check whether the data object has validation errors and decide whether to save it to the database.
                                Therefore, everything will be implemented in the view model the way you wish.

                                Thanks,
                                Ted

                                0

                                Hi again
                                I've attached some sample about what I want to accomplish.
                                Thank you again.

                                MvvmLightValidation.zip
                                0

                                Forgot to say I am using EF
                                In that sample is a simple class as database

                                0

                                Hi Sorin,

                                Thank you for the sample project. I need some time to modify it in order to illustrate how to provide the validation in a way you wish. I will get back to you as soon as possible. Please wait a while.

                                Thanks,
                                Ted

                                0

                                I've implemented something like here
                                http://stackoverflow.com/questions/3492777/validation-in-mvvm-model
                                If you find an easier solution please inform.
                                Anyway with this solution I have a problem with NullValue and/or TargetNullValue.
                                If I set them and the editor has a null value it displays the text. but After starting to type some text in TextEdit it remains the NullText and the new text it's appended.
                                Is it normal ?
                                Thank you

                                0

                                Hi Sorin,

                                I have implemented another approach that is described in the "Data Validation" part of the Data Binding Overview MSDN article. I have created a validation rule and used it in the binding expression. Attached is the modified sample project that illustrates this approach. Data is validated after it is typed in the editor, however it will not be saved until the validation is passed. Anyway, it seems that this conversion is far beyond the bounds of our control usage.

                                As for NullText, I'm afraid the issue isn't quite clear to me. I have tried to use NullText properties with the validation approach I implemented, but haven't encountered any issue. Please clarify what issue you're talking about.

                                Thanks,
                                Ted

                                dxSample.zip

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners