c# - TextBox is not invalidated for the second time -
On the button click, I'm validating that the value in the text box is valid:
TxtName .GetBindingExpression (TextBox.TextProperty) .UpdateSource ();
And the text box is highlighted near the red border and error tip.
Then I switch to another tab. Come back - clicking on the text box has not highlighted any more, I confirm again and the verification rule works fine and wrong, but the textbox is still not highlighted.
How to highlight textbox again as invalid?
Validation rules:
public class text Requirement: Validation rules {public override Validation functions validate (Object value, Kalcrinfo Kalcrinfo) {var text = Value as string; Return new verification (string. ISNLLarlety (text), "Please, enter ALLEY"); }}
Verification error ad (red rectangle) is being displayed in a drunken The layer that is related to some ancestors of TabControl
when you switch tabs, the contents of the original tab are fluctuating, and at that point, the adorner is removed from the adorner layer, because The alcoholic and his decorative elements are no longer in the same view tree. However, when you switch back to the original tab, the adder is not being reconnected again. This is the weakness of WPF verification support. I do not know that this is due to the design or inspection, but the solution is very easy.
Just wrap the contents of your tab items in a AdornerDecorator
This error ad will be added to the within tab in the adorner layer, where it will remain the same even if the tab's content fluctuates. When you switch back, it will still happen.
& lt; TabItem & gt; & Lt; AdornerDecorator & gt; & Lt ;! - Tab Content - & gt; & Lt; / AdornerDecorator & gt; & Lt; / TabItem & gt;
Comments
Post a Comment