共用方式為


Center (RadialGradientBrush)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the center of the outermost circle of the radial gradient.

<object Center="Point"  .../>
value = object.Center
object.Center = value

Property Value

Type: Point

The two-dimensional point that is located at the center of the radial gradient.

This property is read/write. The default value is a point with value 0.5,0.5.

Managed Equivalent

Center

Remarks

The default central point location of the gradient circle is (0.5, 0.5).

See the "Remarks" section in the Point reference topic for scripting usages of this property.

The MappingMode property of a RadialGradientBrush determines whether the object's coordinate properties are interpreted as relative or absolute values. By default, Center is treated as relative, which corresponds to a MappingMode of RelativeToBoundingBox. A MappingMode of Absolute specifies that the Center value is expressed in coordinate pixels, not as a factor within the bounding box of the area where the brush is applied.

Example

The following XAML example shows some RadialGradientBrush attribute usages.

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">

  <!-- This rectangle is painted with a radial gradient. -->
  <Rectangle Width="200" Height="100">
    <Rectangle.Fill>
      <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5"
        RadiusX="0.5" RadiusY="0.5">
        <GradientStop Color="Yellow" Offset="0" />
        <GradientStop Color="Red" Offset="0.25" />
        <GradientStop Color="Blue" Offset="0.75" />
        <GradientStop Color="LimeGreen" Offset="1" />
      </RadialGradientBrush>
    </Rectangle.Fill>
  </Rectangle> 
  
</Canvas>

Applies To

RadialGradientBrush

See Also

Reference