c# - Complex MultiBinding validation -
i have form has multiple fields. have "validate" button action db input. button activated if bare minimum fields defined user.
so far quite simple fields text:
<button x:name="manage" content="manage"> <button.isenabled> <multibinding mode="oneway" converter="{staticresource fieldsfilledintovisible}"> <binding elementname="name1" path="text"/> <binding elementname="name2" path="text"/> </multibinding> </button.isenabled> </button>
converter being:
public class allvaluesdefinedconverter : imultivalueconverter { public object convert(object[] values, type targettype, object parameter, cultureinfo culture) { bool isenabled = false; (int = 0; < values.length; i++) { isenabled = isenabled || string.isnullorempty(values[i].tostring()); } return !isenabled; } public object[] convertback(object value, type[] targettypes, object parameter, cultureinfo culture) { return null; } }
but have consider check boxes, condition should [any of these checkboxes checked + previous text fields defined --> activate validation button]:
<wrappanel style="{staticresource wrapstyle_inputs}"> <checkbox content="check1" ischecked="{binding checked1, mode=twoway}"/> <checkbox content="check2" ischecked="{binding checked2, mode=twoway}"/> <checkbox content="check3" ischecked="{binding checked3, mode=twoway}"/> </wrappanel>
would know how so?
thank you!
converters wrong tool job. should instead @ validation, commands, , view models. view model implement validation logic , expose command button bound to. command executable if validation logic passes.
Comments
Post a Comment