Is there an easy way to have XamMaskedInput validate and set the Validation.HasErrors and related attached properties like other WPF controls?
I realize that the mask is supposed to prevent bad data in the first place. But if the user initiates a save operation and the value is still focused and is still invalid (has InvalidValueErrorInfo) then ideally we would be able to programmatically detect the invalid data with program logic that is generic (ie. Validation.HasErrors). Its kind of a pain to create special-purpose code for ValueInput-derived controls.
Hello dbeavon,
Thank you for your post!
I have been looking into your question. You can set the ValueConstraint properties for the XamMaskedInput. Using them you can set a range of numbers, that you want the user to be able to enter in the input. More about the ValueConstraints you can find on the following link from our documentation: http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/InfragisticsWPF4.Controls.Editors.XamMaskedInput.v14.2~Infragistics.Controls.Editors.ValueInput~InvalidValueBehavior.html.
Would you please provide me with more detailed information about your scenario and the functionality you want to achieve, in order for me to be able to further investigate this issue you?
Looking forward to hearing from you.
In my case the mask of the XmlMaskedInput is simply as follows : (Mask="hh:mm").
I noticed that the source is updated as the user types (instead of on losing focus). But they can still use the save command before the data is valid (eg the mm part may still be blank).
I'd like for the XmlMaskedInput to show the red decorator and use the Validation.HasErrors attached property in this case. Is there any way for the control to do this out of the box?
Thank you for the provided information.
I have been looking into it and I have one more question about you. Are you using the XamMaskedInput as an editor in one of our grid or you use the input alone?
It is stand-alone on a user control. (In the case of grids, I noticed a separate set of controls (Windows.Editors) for xamDataGrid.)
BTW, are there docs that compare those two namespaces? I get the feeling that one predates the other by many years.
After further researching your issue I have created a small sample application for you.
In the sample application I have a simple XamMaskedInput. I also create two styles - one when there is an invalid value and one when the value is valid.
Then I have handled the ValidationError event of the XamMaskedInput. This event fires when the user leaves the input with an error in it. In the handler of the event I assign the error style for the XamMaskedInput.
The other event, that I have handled is the ValueChanged event. In the handler of this event I check if the IsValueValid property is true. If it is I change the style for the XamMaskedInput.
More about the events, that I have used you can find on the following link from our documentation: http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=InfragisticsWPF4.Controls.Editors.XamMaskedInput.v14.2~Infragistics.Controls.Editors.XamMaskedInput_members.html.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Gergana,
Thanks for your help with this sample.
I probably wasn't clear enough in my original post but I was looking for the XamMaskedInput to interact with the standard API for "System.Windows.Controls.Validation". (eg. equivalent to manually executing MarkInvalid and ClearInvalid). It doesn't seem like the input control has any built-in features for this like the standard TextBox and other types of WPF System.Windows.Controls.
Using the events you've pointed me to, I am able to manually attach error information at will and clear it out again. Styling is then based on the attached property. That should be good enough for most purposes, although it could become repetitive to put this in place with every use of the XamMaskedInput.
I do appreciate your help. Hopefully some day in the future your input controls will conform to the API for "System.Windows.Controls.Validation".
Thanks, David
Hello David,
I am just checking if you have any further questions on this matter. Please do not hesitate to let me know if you do.
Thank you for the feedback. I am glad that you have found a solution to your issue.
Also if you want the inputs to have a built-in features for the API, that you have mentioned, you can suggest a new Product Idea for future versions (or vote for existing ones) at http://ideas.infragistics.com.
Steps to create your idea:
1. Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).
2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
3. Add your product idea and be sure to be specific and provide as much detail as possible.
• Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
• [CASE: “Reference case [case number], FORUMS: “Include a link to this thread”] in your idea so product management will be able to look back at this case.
The benefits of submitting the product idea yourself include:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
Additional benefits of the Product Idea system include:
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
- Allow you to shape the future of our products by requesting new controls and products altogether.
- You and other developers can discuss existing product ideas with members of our Product Management team.
The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Thank you for contacting Infragistics.