About the color selector in WP7

Source: Internet
Author: User
We often use a color selection box for winform programs, but this class is not provided in WP7 for our call. Today we see an open-source project coding4fun, the following describes how to use the hexagonal color selection box: first download to the DLL package we want to use. The address will be provided later in the blog. Create a project in vs2010, add reference, and add namespace declaration in the mainpage. XAML file header. Then add the following code directly to the place where the hexagonal color selection box needs to be added:

<c4fControls:ColorHexagonPicker />

The effect is as follows:Coding4fun provides the following attributes for this hexagonal color extraction device:

  • Color
This is a color independent attribute, which determines the color selection result in the face color selector. Type: Color
  • Colorbrightnesssteps
Color brightness step, type: int
  • Colordarknesssteps
Color darkness step, type: int
  • Colorsize
Color: select the size of the rectangle, type: double
  • Greyscalesteps
The step of the gray value, type int
  • Solidcolorbrush
The following is an example of the selected color painter. You can check the effect by referring to the Code:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <c4fControls:ColorHexagonPicker  ColorSize="10" ColorBrightnessSteps="3" Margin="-147,22,147,75" Height="510" Width="456" />            <c4fControls:ColorHexagonPicker  ColorSize="10" ColorBrightnessSteps="5" Margin="9,22,-9,75" Height="510" Width="456" />            <c4fControls:ColorHexagonPicker  ColorSize="10" ColorDarknessSteps="3" Margin="-125,210,125,-113" Height="510" Width="456" />            <c4fControls:ColorHexagonPicker  ColorSize="10" ColorDarknessSteps="5" Margin="53,210,-53,-113" Height="510" Width="456" />            <c4fControls:ColorHexagonPicker  ColorSize="10" GreyScaleSteps="3" Margin="-125,416,125,-319" Height="510" Width="456" />            <c4fControls:ColorHexagonPicker  ColorSize="10" GreyScaleSteps="5" Margin="76,441,-76,-344" Height="510" Width="456" /></Grid>
To set a region without hexagonal colors, see the following code:
<c4fControls:ColorHexagonPicker ColorSize="20" ColorDarknessSteps="0" ColorBrightnessSteps="0" Margin="94,260,-94,-163" Height="510" Width="456" />
Next is an example of color paint brush binding. Front-end binding:
<Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <c4fcontrols: colorhexagonpicker colorsize = "20" name = "colorpicker" margin = "-6, 6, 91 "Height =" 510 "width =" 456 "/> <rectangle Height =" 80 "horizontalalignment =" Left "fill =" {binding elementname = colorpicker, path = solidcolorbrush} "margin =" 143,366, 146 "name =" rectangle1 "stroke =" black "strokethickness =" 1 "verticalignment =" TOP "width =" "/> <textblock fontsize =" 30 "Height =" 40 "horizontalalignment =" Left "margin =" 12,366, 125 "name =" textblock1 "text =" color binding: "verticalalignment =" TOP "width =" "/> </GRID>
Use the colorchanged event to bind the background:
<Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <c4fcontrols: colorhexagonpicker colorsize = "20" name = "colorpicker" colorchanged = "colorpicker_colorchanged" margin = "-6, 6, 91 "Height =" 510 "width =" 456 "/> <rectangle Height =" 80 "horizontalalignment =" Left "margin =" 143,366, 146 "name =" rectangle1 "stroke =" black "strokethickness =" 1 "verticalignment =" TOP "width =" "/> <textblock fontsize =" 30 "Height =" 40 "horizontalalignment =" Left "margin =" 12,366, 125 "name =" textblock1 "text =" color binding: "verticalalignment =" TOP "width =" "/> </GRID>
 private void ColorPicker_ColorChanged(object sender, Color color)        {            this.rectangle1.Fill = new SolidColorBrush(color);        }
Source Project address: coding4fun

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.