Hello everyone,
I've got the the attached user control .It's work just fine accept for the fact that I can't see the tooltip.
Can you please tell me what I'm missing?
Thanks' in advance,
Lior
<UserControl.Resources>
<Style TargetType="{x:Type TextBox}" x:Key="IDValid">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Right" Foreground="Red" FontSize="14" FontWeight="Bold"
ToolTip="{Binding ElementName=Holder,Path=AdornedElement.(Validation.Errors)[0].ErrorContent.ToString()}">!!!TextBlock>
<Border BorderBrush="Red" BorderThickness="2">
<AdornedElementPlaceholder Name="Holder">AdornedElementPlaceholder>
Border>
DockPanel>
ControlTemplate>
Setter.Value>
Setter>
Style>
UserControl.Resources>
<TextBox Width="{Binding RelativeSource={RelativeSource Self}, Path=Parent.Width}" Height="{Binding RelativeSource={RelativeSource Self}, Path=Parent.Height}"
Style="{StaticResource IDValid}" >
<TextBox.Text>
<Binding ElementName="This" Path="ID" NotifyOnValidationError="True">
<Binding.ValidationRules>
<local:IdValidation />
Binding.ValidationRules>
Binding>
TextBox.Text>
TextBox>
UserControl>
Loading
Lior KooznitsPosted Aug 8, 2009, 11:58 AM
I sent you an email a few days ago, have you received it?
Thanks',
Lior
Roei BarPosted Aug 5, 2009, 1:25 AM
Lior KooznitsPosted Aug 4, 2009, 6:17 PM
Of course that I've got all of this in my code.
Here is my decleration (as you can see, I used it inside the TextBox.Text propery ):
xmlns:local="clr-namespace:UserControls.General"
And here is my code:
public class IdValidation : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
Double temp;
if (value.ToString().Length != 9 && Double.TryParse(value.ToString(), out temp))
return new ValidationResult(false,"Bla bla bla");
return new ValidationResult(true, null);
}
}
Roei BarPosted Aug 4, 2009, 5:24 PM