Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validation.HasError and IndexOutOfRange oddity
Message
From
30/10/2009 14:35:55
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
Validation.HasError and IndexOutOfRange oddity
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01432419
Message ID:
01432419
Views:
70
Hi,
I have this trigger defined to set the ToolTip on a TextBox to show the current error:
 <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                        Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                        Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
At runtime it gives the expected result but when monitoring the Output window I see that often (but not always) an ArgumentOutOfRange exception is thrown. Although this doesn't affect the behaviour that I need I find it annoying and can't see why it is happening.
To my way of thinking if the Trigger fires then by definition the Validation.Errors array should be populated but, if I interpret the error correctly, it is *not*
I can't even discern a pattern for when this error occurs....
Any enlightenment?
TIA
Viv
Reply
Map
View

Click here to load this message in the networking platform