Expression blend custom radiobutton Template

Source: Internet
Author: User

You can use a template in WPF or Silverlight to modify the structure of controls that apply the template. You can modify the control template to rearrange, add, or delete elements (or widgets) in the control ).

The following uses a demo to demonstrate how to use expression blend to edit a shape template.

 

Create a Silverlight project named radiobuttontemplate and add a radiobutton to the grid named rbred, as shown in figure

 

Right-click rbred and choose edit template> Create empty... Create an empty template, as shown in figure

 

Apply it to rbred, as shown in figure

 

Click OK to edit the template and add a rectangle of 30*30, as shown in figure

 

Rename the rectangle as uncheck, and adjust its rounded corner to drag it into a circle, as shown in

 

Select uncheck, modify its stroke, and set the garden to borderless, as shown in figure

 

Select, uncheck, use Ctrl + C, CTRL + V to copy, and name the copied rectangle as check, as shown in figure

 

Navigate to the State panel, edit the template, select checked, and record the radiobutton style when radiobutton is selected.

 

Set the background color of the check rectangle. Here, select the gradient brush, for example:

 

Switch to unchecked, select the uncheck rectangle, and set its background color to solid solor, pure red (# ff000000), as shown in figure

 

Click the following button to exit template editing, as shown in figure

 

Select rbred and set its background color to red.

 

Copy rbred and name it rbgreen and rbblue respectively. Repeat the preceding steps to edit the template.

Add a rectangle to the grid named showcolor to display the background color of the selected radiobutton, for example:

 

CompileCodePreviously, we had to set rbred, rbgreen, and rbblue as a group and set their groupnames to showcolor.

 

And set the checked events of the three radiobutton to colorchanged.

 

Write the following code in code-behind:

Press F5 to runProgram, The final effect is as follows:

How about it? A beautiful radiobutton will soon be implemented. You can also define other behaviors, such as an animation when moving to radiobutton. Please act on your own!

 

Source codeDownload

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.