Hi everyone
I have a wpf window having 4 XamTextEditor controls.
for that i have set the TabIndex as (0,1,2,3) and can do tab navigation.
Now the requirement is
i have a validation on the XamTextEditor4 (on the EditModeEnded event of the control i am doing a validation if value is not correct in the XamTextEditor i display a messagebox showing the error)
Now the problem is if the value is wrong an errorMessagebox is displayed .But if i click yes on the messagebox Button the tab is navigationg to the next control.(for my case to the next window.)
I need to control this behaviour .That means if validation fails i need to stop the tab navigation and bring the focus to the same XamTextEditor4 .
please suggest a solution
Note: I have used textBox.MoveFocus to previous and textbox.focus() etc.None works
Thanks SNA
With regards to #1, I think my original test was using a ValueContraint as well so that prevent the focus lost. Since you're doing your own validation you'll probably need to handle retaining focus. Maybe you can look into handling the PreviewLostKeyboardFocus event if the e.NewFocus is something outside the editor control.
With regards to #2, I don't have any examples as this is not specific to our controls. ValidationRule is a class defined in the WPF framework so you might check the MS documentation or MS forums for examples of validation rules.
Hi ,
1) The first option e.cancel in EditModeEnding is not working.I have tested this.This works if i press enter after entering the value.But if i press tab it ignore the "cancel" and go to the nextt control.
2) For the second option can you give me some examples of validation rules.
My requirement is
I have 4 XamtextEditor controls in the page.
if i enter a value in the XamtextEditor4 ,the value should not be greater than XamtextEditor3 and XamtextEditor2
So if validation fails the tab navigation should stop and the tab focus should be on XamtextEditor4
Please suggest
Perhaps you should handle the EditModeEnding event instead and cancel exiting edit mode? Another alternative would be to try and use the ValueConstraint to validate your data. Aside from the various properties it exposes (MinLength, RegEx, MinInclusive, etc.), in 9.2 it also exposes a ValidationRules property so you could provide custom ValidationRule instances that will be evaluated when the value needs to be validated.