c# - WPF PasswordBox hint not working -
i'm trying style passwordbox in wpf can show hint. i'm doing using following code in resourcedictionary:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:budgetbuddy.styles"> <style x:key="pbhintstyle" targettype="{x:type passwordbox}"> <setter property="background" value="{dynamicresource {x:static systemcolors.windowbrushkey}}"/> <setter property="borderbrush" value="#ffabadb3"/> <setter property="foreground" value="{dynamicresource {x:static systemcolors.controltextbrushkey}}"/> <setter property="borderthickness" value="1"/> <setter property="keyboardnavigation.tabnavigation" value="none"/> <setter property="horizontalcontentalignment" value="left"/> <setter property="focusvisualstyle" value="{x:null}"/> <setter property="allowdrop" value="true"/> <setter property="scrollviewer.panningmode" value="verticalfirst"/> <setter property="stylus.isflicksenabled" value="false"/> <setter property="template"> <setter.value> <controltemplate targettype="{x:type passwordbox}"> <border x:name="border" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" background="{templatebinding background}" snapstodevicepixels="true" cornerradius="4" padding="5 2 0 0"> <grid> <scrollviewer x:name="part_contenthost" focusable="false" horizontalscrollbarvisibility="hidden" verticalscrollbarvisibility="hidden"/> <textblock x:name="warktext" text="{templatebinding tag}" foreground="dimgray" visibility="collapsed" /> </grid> </border> <controltemplate.triggers> <trigger property="isenabled" value="false"> <setter property="opacity" targetname="border" value="0.56"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="borderbrush" targetname="border" value="#ff7eb4ea"/> </trigger> <trigger property="iskeyboardfocused" value="true"> <setter property="borderbrush" targetname="border" value="#ff569de5"/> </trigger> <multitrigger> <multitrigger.conditions> <condition property="isfocused" value="false"/> </multitrigger.conditions> <setter property="visibility" targetname="warktext" value="visible"/> </multitrigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> <style.triggers> <multitrigger> <multitrigger.conditions> <condition property="isinactiveselectionhighlightenabled" value="true"/> <condition property="isselectionactive" value="false"/> </multitrigger.conditions> <setter property="selectionbrush" value="{dynamicresource {x:static systemcolors.inactiveselectionhighlightbrushkey}}"/> </multitrigger> </style.triggers> </style> </resourcedictionary>
this code works problem. shows hint, shows chars password chars problem after typing password in field shows hint on password chars.
here screenshots:
here problem:
how fix this? in advance. :)
you can try :
<multitrigger> <multitrigger.conditions> <condition property="isfocused" value="false"/> <condition property="text" value=""/> </multitrigger.conditions> <setter property="visibility" targetname="warktext" value="visible"/> </multitrigger> <multitrigger> <multitrigger.conditions> <condition property="isfocused" value="false"/> <condition property="text" value="{x:null}"/> </multitrigger.conditions> <setter property="visibility" targetname="warktext" value="visible"/> </multitrigger>
if text not empty or null, hint shown, otherwise no.
hope you.
Comments
Post a Comment