Learning Silverlight 2 Series (9): Using Control templates

Source: Internet
Author: User
Tags silverlight

This article is the Nineth article in the series, which describes how to customize the perception of a control using a control template. Silverlight provides an extremely powerful feature that allows users to fully customize the appearance of a control.

Customizing control content

In Silverlight, the WatermarkedTextBox control can provide a hint for the user's input, and if it's simply a bit of textual information, sometimes it seems monotonous, and if you add the corresponding picture to the effect will be better, as shown in the following figure a simple user login interface:

This looks like the interface is much more vivid, and the XAML declaration is as follows:

<canvas background= "#46461F" >
<watermarkedtextbox x:name= "UserName" canvas.top= "canvas.left=" 50 "
Width= "height=" >
<WatermarkedTextBox.Watermark>
<stackpanel width= "height=" orientation= "Horizontal" >
<image source= "Admin.png" horizontalalignment= "left" ></Image>
<textblock text= "Please enter user name" verticalalignment= "Center" foreground= "#999999"/>
</StackPanel>
</WatermarkedTextBox.Watermark>
</WatermarkedTextBox>
  
<watermarkedtextbox x:name= "Password" canvas.top= "50" canvas.left= "
Width= "height=" horizontalalignment= "left" >
<WatermarkedTextBox.Watermark>
<stackpanel width= "height=" orientation= "Horizontal" >
<image source= "Lock.png" horizontalalignment= "left" ></Image>
<textblock text= "Please enter password" verticalalignment= "Center" foreground= "#999999"/>
</StackPanel>
</WatermarkedTextBox.Watermark>
</WatermarkedTextBox>
  
<button canvas.top= "180" canvas.left= "100"
Width= "height=" >
<Button.Content>
<stackpanel orientation= "Horizontal" >
<image source= "Apply.png" horizontalalignment= "left" ></Image>
<textblock text= "Login" verticalalignment= "Center" margin= "0 0 0" ></TextBlock>
</StackPanel>
</Button.Content>
</Button>
</Canvas>

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.