The implementation of the placeholder behavior Placeholderbehavior and the use

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.