Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After much, much research and frustration, I believe it to be related to this: <a href="http://blogs.msdn.com/silverlight_sdk/archive/2008/10/24/loaded-event-timing-in-silverlight.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/silverlight_sdk/archive/2008/10/24/loaded-event-timing-in-silverlight.aspx</a></p> <p>The Loaded event in Silverlight does not match the definition of (a) what it is in WPF and consequently (b) the definition that they pasted into the Silverlight documentation from WPF</p> <p>WTF???</p> <p>I have modified some code based on the above and now it does not seem to fail. I wish I could tell you exactly why it did what did and why what I did fixed it (or at least masked it again??), but I can't. Maybe someone else will encounter this and can figure it out.</p> <p>Here is what I was doing and what I changed:</p> <p>The Textbox above makes use of an Attached Property for a Validator (like the ASP.NET validators and similar to the ones in the Silverlight Toolkit). When a Validator (base class for RequireValidator) is attached to a control, it links to the control to provide validation as an attached behavior. The trick is that it then tries to Validate() the current control. For a RequiredValidator on a TextBox control it calls string.IsNullOrEmpty() for the Text property on the linkedControl. All of this works fine as these are just properties on the TextBox Control. However, just after that, the validator needs to somehow tell the control to display the error indicator and any error message. I do this through providing a custom Style that includes two new VisualStates ("ValidInput" &amp; "InvalidInput") in their own VisualStateGroup ("ValidationStates") and that one of the Style's Elements is a Control that supports and interface called IValidationNotificationControl. </p> <p>Ok, enough background. From the documentation, I knew that I could only access the elements of the TextBox Style (the new visualStates and the notification icon) AFTER the template had been applied so I hooked into the Loaded event for the linkelement for the validator and called Validate() there for the first time. Well, someone at MS saved about 15 minutes by copying an pasting the Loaded Event description from WPF and that cost me about 3-4 days of heartache. Turns out that there is no guarantee that the template is applied then in Loaded Event in silverlight. So, I simply added a call to ApplyTemplate() in the Loaded event handler for the linkedelement and the failure went away.</p> <p>My guess is that the error was intermittent because the Layout (and therefore the application of the Template) occurs asynchronously and sometimes it was there when I hit the Loaded Event and sometimes it was not. But I still think that it is a Silverlight Bug as to where the error manifested itself and may even point to a security hole (if, but some action, somewhere else in the code, I can cause the XAML Parser to return a type different than what teh actual XAMl indicates...). Oh well...it seems to be working now. Maybe this will help someone else.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload