I have UserControl bounded to my view model. View model implements IDataErrorInfo. UserConrol has Validation.ErrorTemplate. In this template I use converter to show tooltip with errors:
<UserControl.Style>
<Style TargetType="{x:Type UserControl}">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel>
<AdornedElementPlaceholder x:Name="adorner">
<Image x:Name="imgError"
Width="32"
Height="32"
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
ToolTip="{Binding ElementName=adorner,Path=AdornedElement.(Validation.Errors),Converter={StaticResource ValidationErrors2TooltipConverter},ConverterParameter='Couldn't save hour work:'}"
Source="{StaticResource ErrorDrawingImage}" />
</AdornedElementPlaceholder>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Style>
When I change some property (for instance: ComboBox‘s selection), the number of error should change, but it doesn’t. I couldn’t find a way to refresh errors in ToolTip.
Questions:
- How could I refresh errors in
ToolTip. - Validation works fine for
UserControl, but doesn’t work for components inside it. I definedValidation.ErrorTemplate‘s for components inUserControl, but they are not visible, however controls bounded to view models (withIDataErrorInfo).
The validation pattern must be applied for each control inside your UserControl. There’s no “inheritance”.