silverlight 5.0 - Databinding validation does not catch exceptions -



silverlight 5.0 - Databinding validation does not catch exceptions -

i bound textbox object in memory throws exception when wrong value entered.

if textbox has validatesonexception set true , mode=twoway, if exception should occur should intercepted binding, it's not.

the textbox looks like:

<textbox name="txtage" text="{binding age, mode=twoway, validatesonexceptions=true}" />

i created object in memory , set layoutroot grid's datacontext created object in usercontrol's constructor.

student std = new student(); layoutroot.datacontext = std;

the bound object type is:

public class pupil { private string _name; public string name { { homecoming _name; } set { _name = value; } } private int _age; public int age { { homecoming _age; } set { if (value > 100 || value < 0) { throw new exception("please come in age between 0 - 100"); } _age = value; } } }

the exception thrown property age when number < 0 or > 100 entered should intercepted.

this behavior expect:

but exception instead.

i'm studying validation blog found http://www.codeproject.com/articles/86955/silverlight-4-data-validation-tip-of-the-day-part

this step 8, should behavior, author explains notifyonvalidationerror , bindingvalidationerror beyond step.

what setting failing make?

thanks in advance,

rafael

you disable breaking on user-unhandled exceptions, or add together exception list of exceptions not break on (from here)

go debug -> exceptions -> , uncheck exception, i.e. system.componentmodel.dataannotation.validationexception

or, comment here, apply [system.diagnostics.debuggerhidden()] attribute on property. ("notice may still vs just-in-time debugger dialog asking whether want debug it.")

validation silverlight-5.0

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -