GradientBrush.SpreadMethod 屬性

定義

取得或設定展開方法的類型,該類型指定如何繪製在所要繪製物件之邊界內開始或結束的漸層。

public:
 property System::Windows::Media::GradientSpreadMethod SpreadMethod { System::Windows::Media::GradientSpreadMethod get(); void set(System::Windows::Media::GradientSpreadMethod value); };
public System.Windows.Media.GradientSpreadMethod SpreadMethod { get; set; }
member this.SpreadMethod : System.Windows.Media.GradientSpreadMethod with get, set
Public Property SpreadMethod As GradientSpreadMethod

屬性值

GradientSpreadMethod

用來繪製漸層之擴展方法的型別。 預設為 Pad

範例

下列範例會將不同的 SpreadMethod 設定套用至數 LinearGradientBrush 個 和 RadialGradientBrush 物件。

<Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  Title="Gradient Spread Methods">
  <StackPanel>

    <!-- The following three examples show the different gradient spread methods
         applied to linear gradient brushes. -->
    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Pad -->
        <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Pad">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Reflect -->
        <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Reflect">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Repeat -->
        <LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Repeat">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <!-- The following three examples show the different gradient spread methods
         applied to radial gradient brushes. -->
    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Pad -->
        <RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Pad">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Reflect -->
        <RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Reflect">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle Width="150" Height="75" Stroke="Black">
      <Rectangle.Fill>

        <!-- Repeat -->
        <RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Repeat">
          <GradientStop Color="White" Offset="0" />
          <GradientStop Color="#333333" Offset="1" />
        </RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

  </StackPanel>
</Page>

備註

下圖顯示可用的散佈方法及其對 LinearGradientBrushRadialGradientBrush 的影響。 紅色線條表示漸層空間。 會 LinearGradientBrush 定義其漸層空間及其 StartPointEndPoint 屬性。 會 RadialGradientBrush 定義其漸層空間及其 CenterRadiusXRadiusY 屬性。

不同的 GradientSpread 設定
漸層散佈方法

相依性屬性資訊

識別碼欄位 SpreadMethodProperty
中繼資料屬性設定為 true

適用於

另請參閱