1

A VS2017 solution illustrating this issue: https://github.com/ShannonZ/playground.git

IDataErrorInfo I implemented IDataErrorInfo in my ViewModel class. ViewModel only has two props X & Y and X+Y should not be larger than 10.

ValidatesOnDataErrors=True All TextBox binding to X/Y were set ValidatesOnDataErrors=True

What's QUIRK The two TextBox-es were red highlighted because X+Y=13>10 at beginning. Then if you change to the second TabItem and go back to the first one again, the two TextBox-es shows in a normal state. Even if you change the value manually (keep X+Y>10), the Error infos would not show again. enter image description here How to solve this problem?

Shannon
  • 323
  • 1
  • 11

2 Answers2

0

It may be due to the fact that tabitem contents are unloaded when you change tab. Look at this post

  • Not caused by TabItem unload or Virtualization because if there were no errors before changing to another item, after changing back, the Data Validation performed well. – Shannon Mar 12 '18 at 03:03
0

After several days tracking and inspecting, I found that the Validation.Error informations are shown in the Adorner Layer, when you switch tabs, that layer is discarded. The way to solve it is simple: Add content inside an AdornerDecorator.

<TabItem>
<AdornerDecorator>
    <Grid>

    </Grid>
</AdornerDecorator>

Shannon
  • 323
  • 1
  • 11