The reason is also very direct, the boss need, a start for the TextBox worry, find this control make use of, as to copyright, internal tools also do not sell, and I do not understand English, also ignored:
Extended WPF toolkit™community EditionOthers are professional, so I do not study the technical aspects, but the password box can not add watermarks, which is quite boring. Really lazy to engage in the control, wrote a style to do with: hint watermark is to write dead, after all, is the original control, do not make the use of, see not the past to write a control it.
1 <Stylex:key= "PasswordBoxStyle1"TargetType="{x:type PasswordBox}">2 <Setter Property= "BorderThickness"Value= "1"/>3 <Setter Property= "Padding"Value= "2"/>4 <Setter Property= "Template">5 <Setter.value>6 <ControlTemplateTargetType="{x:type PasswordBox}">7 <Borderx:name= "Bd"Snapstodevicepixels= "true"borderthickness="{TemplateBinding BorderThickness}"Background="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}">8 <GridMargin="{TemplateBinding Padding}">9 <ScrollViewerx:name= "PART_ContentHost"Snapstodevicepixels="{TemplateBinding Snapstodevicepixels}" />Ten <TextBlockx:name= "Water"HorizontalAlignment= "Left"VerticalAlignment= "Center"Foreground= "Lightgray"FontSize="{TemplateBinding FontSize}" One Text= "Please enter password"Visibility= "Hidden"/> A </Grid> - </Border> - the <controltemplate.triggers> - <Trigger Property= "IsEnabled"Value= "false"> - <Setter Property= "Background"TargetName= "Bd"Value="{dynamicresource {x:static Systemcolors.controlbrushkey}}"/> - <Setter Property= "Foreground"Value="{dynamicresource {x:static Systemcolors.graytextbrushkey}}"/> + </Trigger> - <MultiTrigger> + <multitrigger.conditions> A <Condition Property= "IsFocused"Value= "false"/> at <Condition Property= "Extentwidth"Value= "0"SourceName= "PART_ContentHost"/> - </multitrigger.conditions> - <Setter Property= "Visibility"Value= "Visible"TargetName= "Water"/> - </MultiTrigger> - </controltemplate.triggers> - </ControlTemplate> in </Setter.value> - </Setter> to </Style>
PasswordBoxStyle1
WPF adds a watermark to the PasswordBox control, the lowest-level version