c# - WPF: Validation.ErrorTemplate not hidden when adorned control (TextBox) hidden -
i have textbox gets hidden depending on whether item selected in combobox.
this part works fine.
however, has validatesondataerrors set , if textbox has error present, when textbox gets hidden, errortemplate (in adorner layer) remains.
i think understand because errortemplate gets set global adorner layer, doesn't realize textblock, has no logical connection to, has been hidden.
any thoughts on how work or around this? i've tried adding explicit adornerdecorator inside grid, bound combobox value.
you apparently can bind visibility of adornerelementplaceholder
of adorner itself. here code:
<controltemplate x:key="emptyerrortemplate"> <border background="transparent" borderbrush="transparent" borderthickness="0" ishittestvisible="false" visibility="{binding elementname=placeholder, path=adornedelement.visibility}"> <stackpanel orientation="horizontal"> <textblock margin="0,0,-30,0" text="!" foreground="red" fontsize="34" verticalalignment="center"/> <adornedelementplaceholder name="placeholder" /> </stackpanel> </border> </controltemplate>
Comments
Post a Comment