I have a code for Validation.ErrorTemplate:
<Style TargetType="{x:Type TextBox}">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Bottom" Foreground="Red" HorizontalAlignment="Center"
FontSize="14" FontWeight="Bold" Margin="5,0,0,0" ToolTip="{Binding ElementName=adornerPlaceholder, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">{0}</TextBlock>
<AdornedElementPlaceholder Name="adornerPlaceholder"></AdornedElementPlaceholder>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The second part of code, property is:
public string PassWord
{
get { return _passWord; }
set
{
if (_passWord == value)
{
return;
}
_passWord = value;
List<string> errors = new List<string>();
bool valid = true;
if (value == null || value == "")
{
errors.Add("Password can not be empty.");
SetErrors("PassWord", errors);
valid = false;
}
if (valid)
{
ClearErrors("PassWord");
}
OnPropertyChanged(new PropertyChangedEventArgs("PassWord"));
}
}
It works perfectly, but what I want to achieve is how to have full text of error message bellow text box in which data were entered and recognized in my error collection as incorrect?
So, just to have text instead of * and that text should be able to be changed depending on different textbox, as I have many fields to be entered
What I have tried:
Investigated on the net but without success.