最初に私の検証テンプレート
<ControlTemplate x:Key="ValidationTemplate" >
<Grid>
<AdornedElementPlaceholder Name="MyAdornedElement" />
<Path x:Name="path" Margin="-2,-2,0,0" Data="M 0,10 L 10,0 L 0,0 Z" Fill="{StaticResource BrushError}" StrokeThickness="2" Stroke="White"
Visibility="{Binding ElementName=MyAdornedElement,Path=AdornedElement.Visibility}"
ToolTip="{Binding ElementName=MyAdornedElement,Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent}"/>
</Grid>
</ControlTemplate>
そして私のテキストボックススタイル
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationTemplate}"/>
<Setter Property="UndoLimit" Value="0"/>
<Style.Triggers>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderThickness" Value="{StaticResource IsFocusBorderThickness}"/>
<Setter Property="BorderBrush" Value="{StaticResource IsFocusBorderBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{StaticResource IsDisabledForegroundBrush}"/>
</Trigger>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding Path=(Validation.Errors).CurrentItem.ErrorContent, RelativeSource={x:Static RelativeSource.Self}}"/>
</Trigger>
</Style.Triggers>
</Style>
そして今、謎の行動
2 つのタブページを持つタブ コントロールがあり、各ページにはテキスト ボックスが含まれています。ビューを開いて最初のタブページから 2 番目のタブページに戻り、検証ボタンを押すと、両方のタブページのすべてのテキスト ボックスに検証テンプレートが表示されます。
しかし、ビューを開いてタブページ2に移動せずに検証ボタンを押すと、タブページ1のテキストボックスだけに検証テンプレートが表示されます。さらに、検証テンプレートでボタンをもう一度押すと、タブページ2に表示されません。
私が見逃しているヒントはありますか?
編集: スヌープを使用して、スヌープ ツリービューをタブページ 2 のテキスト ボックスに移動すると、スヌープ ツリービューの TextBox をクリックする限り、検証テンプレート アドーナーが表示されます...