c# - WPF: Additional Red Box around TextBox when ValidationError -


i can't work out why i'm getting additional red border around textbox when validationerror! want border colour around border set in style, there rectangular border around can't figure out how rid off!

see image: enter image description here

this textbox style:

 <style x:key="defaulttextbox" targettype="textbox" xmlns:helpers="clr-namespace:photomanagement.helpers">         <setter property="helpers:watermarktexthelper.ismonitoring" value="true"/>         <setter property="helpers:watermarktexthelper.watermarktext" value="{binding relativesource={relativesource self}, path=tag}" />         <setter property="background" value="#ff22252c" />         <setter property="foreground" value="white" />         <setter property="borderbrush" value="#ff22252c" />         <setter property="width" value="200" />         <setter property="cursor" value="ibeam" />         <setter property="template">             <setter.value>                 <controltemplate targettype="textbox">                     <dockpanel>                         <popup name="errorpopup" isopen="false" placement="top">                             <textblock background="white" foreground="black" text="test" padding="5" />                         </popup>                         <border cornerradius="5"                                      borderbrush="{templatebinding borderbrush}"                                     borderthickness="1"                                     background="{templatebinding background}"                                      margin="3"                                      minwidth="{templatebinding minwidth}">                             <grid>                                 <stackpanel margin="8">                                     <scrollviewer x:name="part_contenthost"/>                                 </stackpanel>                                 <textblock name="part_temptext"                                                 text="{templatebinding tag}"                                                foreground="#ff454954"                                                padding="8"                                                margin="5 0" />                             </grid>                         </border>                     </dockpanel>                     <controltemplate.triggers>                         <trigger property="validation.haserror" value="true">                             <setter property="borderbrush" value="red" />                            <setter targetname="errorpopup" property="isopen" value="true" />                         </trigger>                         <multitrigger>                             <multitrigger.conditions>                                 <condition property="helpers:watermarktexthelper.hastext" value="false"/>                                 <condition property="isfocused" value="true"/>                             </multitrigger.conditions>                             <multitrigger.enteractions>                                 <beginstoryboard storyboard="{staticresource entergotfocus}"/>                             </multitrigger.enteractions>                             <multitrigger.exitactions>                                 <beginstoryboard storyboard="{staticresource exitgotfocus}"/>                             </multitrigger.exitactions>                         </multitrigger>                          <trigger property="helpers:watermarktexthelper.hastext" value="true">                             <trigger.enteractions>                                 <beginstoryboard storyboard="{staticresource enterhastext}"/>                             </trigger.enteractions>                             <trigger.exitactions>                                 <beginstoryboard storyboard="{staticresource exithastext}"/>                             </trigger.exitactions>                         </trigger>                     </controltemplate.triggers>                 </controltemplate>             </setter.value>         </setter>     </style> 

this controltemplate on contentcontrol have posted @ bottom of post, contains textbox's.

<controltemplate x:key="inputfields" targettype="contentcontrol">         <grid>             <i:interaction.triggers>                 <local:routedeventtrigger routedevent="{x:static validation.errorevent}">                     <e2c:eventtocommand                         command="{binding editvm.theentity.conversionerrorcommand, mode=oneway}"                         eventargsconverter="{staticresource bindingerroreventargsconverter}"                         passeventargstocommand="true" />                 </local:routedeventtrigger>                 <local:routedeventtrigger routedevent="{x:static binding.sourceupdatedevent}">                     <e2c:eventtocommand                         command="{binding editvm.theentity.sourceupdatedcommand, mode=oneway}"                         eventargsconverter="{staticresource bindingsourcepropertyconverter}"                         passeventargstocommand="true" />                 </local:routedeventtrigger>             </i:interaction.triggers>             <contentpresenter />         </grid>     </controltemplate>  <style x:key="errortooltip" targettype="control">         <style.triggers>             <trigger property="validation.haserror" value="true">                 <setter property="tooltip" value="{binding relativesource={x:static relativesource.self},                                              path=(validation.errors), converter={staticresource errorcollectionconverter}}"/>             </trigger>         </style.triggers>     </style> 

contentcontrol

<contentcontrol template="{staticresource inputfields}">                     <stackpanel>                         <wrappanel>                             <textbox tag="first name..."                                           text="{binding editvm.theentity.fname,                                     updatesourcetrigger=propertychanged,                                     notifyonsourceupdated=true,                                     notifyonvalidationerror=true,                                     mode=twoway}">                                 <textbox.resources>                                     <style targettype="tooltip">                                         <setter property="staysopen" value="true" />                                         <setter property="placement" value="center" />                                         <setter property="isopen" value="true" />                                     </style>                                 </textbox.resources>                             </textbox>                              <textbox tag="last name..."                                          text="{binding editvm.theentity.lname,                                     updatesourcetrigger=propertychanged,                                     notifyonsourceupdated=true,                                     notifyonvalidationerror=true,                                     mode=twoway}"/>                             <textbox tag="email address..."                                          text="{binding editvm.theentity.email,                                     updatesourcetrigger=propertychanged,                                     notifyonsourceupdated=true,                                     notifyonvalidationerror=true,                                     mode=twoway}"/>                         </wrappanel>                      </stackpanel>                 </contentcontrol> 

not sure if best answer, managed fix adding following textbox style:

<setter property="validation.errortemplate">             <setter.value>                 <controltemplate>                     <adornedelementplaceholder />                 </controltemplate>             </setter.value>         </setter> 

Comments

Popular posts from this blog

shader - OpenGL Shadow Map -

stringtemplate - StringTemplate4 if conditional with length -