You can change the line at which the gradient stops are positioned by setting the StartPoint and EndPoint properties to be different values than the (0,0) and (1,1) starting defaults. The circles mark the position of the gradient stops, and the dashed line shows the gradient axis.Ĭombination of colors specified by the two bounding gradient stops The following image highlights the gradient stops in the previous example. The color of each point between gradient stops is linearly interpolated as a combination of the color specified by the two bounding gradient stops. This example creates a linear gradient with four colors and uses it to paint a Rectangle. At a minimum, a useful LinearGradientBrush should have two GradientStop values, where each GradientStop should specify a different Color and have a different Offset between 0 and 1. An Offset of 1 places the GradientStop at the EndPoint. An Offset of 0 places the GradientStop at the start of the gradient axis, in other words near its StartPoint. The Offset is a double that ranges from 0 to 1. The Offset property of a GradientStop specifies the position of each GradientStop along the gradient axis. You can set the color by using a predefined color name or by specifying the hexadecimal ARGB values. The gradient stop's Color property specifies the color of the gradient stop. A gradient stop specifies what the Color of the brush is at an Offset along the gradient axis, when the brush is applied to the area being painted. The GradientStop is the basic building block of a gradient brush. By default, the gradient axis runs from the upper left corner to the lower right corner of the area that the brush paints, resulting in a diagonal shading. You specify the gradient's colors and their locations along the gradient axis using GradientStop objects. Ī LinearGradientBrush paints an area with a gradient that's defined along a line. The Color of the SolidColorBrush is set to Blue and the Opacity is set to 0.5. The next example creates a Rectangle and explicitly creates the SolidColorBrush as an element value for a Rectangle.Fill property. In the previous examples, the brush being created is created implicitly and automatically, as part of a deliberate XAML language shorthand that helps keep UI definitions simple for the most common cases. For more info on XAML syntax, including property element syntax, see the XAML overview and XAML syntax guide. This syntax is more verbose than the previous methods, but you can specify additional property values on an element, such as the Opacity. You can use property element syntax to define a SolidColorBrush. This XAML example sets the Fill property of a Rectangle to the hexadecimal value "#FFFF0000", and gives an identical result to using the named color Colors.Red. For example, the hexadecimal value "#FFFF0000" defines fully opaque red (alpha="FF", red="FF", green="00", and blue="00"). Two characters in the range 0 to F define each component value, and the component value order of the hexadecimal string is: alpha channel (opacity), red channel, green channel, and blue channel ( ARGB). You can use a hexadecimal format string to declare precise 24-bit color values with 8-bit alpha channel for a SolidColorBrush. For example, to declare a Color value of a SolidColorBrush to represent the named color "Orchid", set the Color value to the static value Colors.Orchid. If you are defining a SolidColorBrush using code rather than XAML, each named color is available as a static property value of the Colors class. Here's an example that sets the Fill property of a Rectangle to the predefined color Red. The 256 named colors are based on the X11 color names from the Cascading Style Sheets, Level 3 (CSS3) specification, so you may already be familiar with this list of named colors if you have previous experience with web development or design. The XAML parser converts the color name to a Color structure with the correct color channels. You can use a predefined color name, such as Yellow or Magenta. In XAML, there are three ways to define a SolidColorBrush and the color it specifies: predefined color names, hexadecimal color values, or the property element syntax. To paint a Shape, text, or parts of a Control that is displayed on the app canvas, set the Fill property of the Shape or the Background and Foreground properties of a Control to a Brush value.Ī SolidColorBrush paints an area with a single Color, such as red or blue. Important APIs: Brush class Introduction to brushes Use Brush objects to paint the interiors and outlines of XAML shapes, text, and controls, making them visible in your application UI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |