GradientBrush.SpreadMethod Właściwość

Definicja

Pobiera lub ustawia typ metody rozprzestrzeniania, który określa sposób rysowania gradientu, który rozpoczyna się lub kończy wewnątrz granic obiektu do malowania.

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

Wartość właściwości

GradientSpreadMethod

Typ metody rozprzestrzeniania używanej do malowania gradientu. Wartość domyślna to Pad.

Przykłady

Poniższy przykład stosuje różne SpreadMethod ustawienia do kilku LinearGradientBrush obiektów i 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>

Uwagi

Poniższa ilustracja przedstawia dostępne metody rozprzestrzeniania oraz ich wpływ na LinearGradientBrush metody i RadialGradientBrush. Czerwona linia wskazuje przestrzeń gradientu. Obiekt LinearGradientBrush definiuje przestrzeń gradientu z jej StartPoint właściwościami i EndPoint . Obiekt RadialGradientBrush definiuje przestrzeń gradientu z właściwościami Center, RadiusXi RadiusY .

Różne ustawienia gradientu powszechnego
Metody rozpraszania gradientu

Informacje dotyczące właściwości zależności

Pole identyfikatora SpreadMethodProperty
Właściwości metadanych ustawione na true Brak

Dotyczy

Zobacz też