I'm not very good at this effect. Placeholder literal placeholder Also some people call this effect the watermark effect is the same as the HTML5 placeholder properties of the effect is intuitive:
How to use:
First download placeholder behavior dll.rar referencing DLLs in your project
1. In vs
Referencing System.Windows.Interactivity.dll assemblies
To add a reference to the Xmal page:
Then attach to the textbox
Set properties for behavior
The text value must be set, this is the text of the hint. Then set other properties as desired. If not set, the default is to take the value of the attached textbox.
2. In Blend
It's very simple in blend, just drag it right down to the textbox.
Setting properties
==================================== Split Line ============================================
This effect is very common and business-independent, making it ideal for behavioral behavior to be used in different projects without having to change the control template.
Introduction of the implementation of the idea:
A TextBox has a constituent part: PART_ContentHost for displaying text
So I think of the simplest way to do this is to add a TextBlock on this part to display the message, in the textbox text of the length>0 hide the textblock,length=0 when the display of the TextBlock
In this case, you need to take this part out, put a grid on it, add TextBlock to the grid, then put the entire grid back in place.
Since the parent of the part can drop this frameworkelement type of part, it must inherit from decorator or a panel. Decorator has a child property, and the Panel has a children attribute. (It is possible for the user to change the control template to a grid, or to inherit from decorator)
In this case, you can find this part and its parent to achieve this effect.
Panel I have considered 4 scenarios: Stackpanel,dockpanel,grid,canvas
dependency property 6: Text,fontsize,foreground,horizontalalignment,verticalalignment,margin
Personal ability is limited, inevitably there is not perfect place, welcome Bo friends to add
Finally attach the full demo source code: Placeholder behavior source code. rar
Recommend a good BLEND,WPF,SL exchange group
Group number: 152049269
Welcome to the Great God, Meng new enthusiastic to join, exchange discussion, common progress!
The implementation of the placeholder behavior Placeholderbehavior and the use