Hi,
Can i block unwanted characters in my XamTextEditor thru xaml ??
Sandeep
Hello Sandeep,
Yes, you can use the ValueConstraint.Enumeration property, which requires an IEnumerable collection of values that can be validated by the ValueConstraint object. In other words the value being validated by this ValueConstraint object will not be considered valid if the value is not part of this enumeration.
Hope this helps,Alex.
Hi Alex,
Thanks for the response. Tried what u said. But it didnt work.
this is what i did.
IList<String> blockedChars = new List<String>();
blockedChars.Add("'");
xamTextEditor1.ValueConstraint.Enumeration = blockedChars;
Anything missing?
Sandeep,
I am actually using an array of strings.
string[] chars = new string[3];
chars[0] = "a";
chars[1] = "b";
chars[2] = "c";
xamTextEditor1.ValueConstraint.Enumeration = chars;
It is also working with:
List<string> chars1 = new List<string>();
chars1.Add("a");
chars1.Add("b");
chars1.Add("c");
Please not that the value of the Editor has to match one of the strings in the collection.
For example : input: a - > correct
input: aa -> incorrect
Alex.
:(
Still not working..
Anything else to do. any other property to be set ??
i pasted the very same code, but no change..
What are the exact DLL versions that you are using. If it is possible, attach a sample project and describe steps to reproduce the issue.
The version of Infragistics3.Wpf.Editors.v8.2 dll is 8.2.20082.200.
Sorry to say that we are denied access for uploading files.
Any way i will giv u the steps which i followed
1. Added a XamTextEditor to a window.
2. Selected the ValueConstraint property of the editor in design mode.
3. Added the following code to the Window_Loaded event.
List<string> chars = new List<string>();
chars.Add("a");
chars.Add("b");
chars.Add("c");
xamTextEditor1.ValueConstraint.ValidateAsType = Infragistics.Windows.Editors.ValidateAsType.Text;
Result: The Editor allows to enter any character
Please verify whether i'm missing anything..
The problem is solved. I was not aware that the validation works when the control loses its focus. My mistake. Sorry..
But instead of specifying the characters to be allowed,
can i tell the chars which i have to block.
any way for this..?
Thanks Alex. I will try with that.
To the best of my knowledge, there is no such way to do this in the xaml. You can also use the regex property of the ValueConstraint and/or handle the keydown/EditModeEnded events.