共用方式為


GradientBrush.ColorInterpolationMode 屬性

定義

取得或設定 ColorInterpolationMode 列舉型別,指定漸層色彩的插補 (Interpolate) 方式。

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

屬性值

ColorInterpolationMode

指定如何插補漸層中的色彩。 預設為 SRgbLinearInterpolation

範例

下列範例顯示兩個具有不同色彩插補模式的類似漸層,這會導致插補在不同的色彩空間中發生。

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

    <Rectangle Width="200" Height="100" Margin="10">
      <Rectangle.Fill>

        <!-- This gradient uses a ColorInterpolationMode of "ScRgbLinearInterpolation"
             which indicates that the colors of the gradient are interpolated using the
             ScRGB color space. -->
        <LinearGradientBrush ColorInterpolationMode="ScRgbLinearInterpolation" 
        StartPoint="0,0.5" EndPoint="1,0.5">
          <LinearGradientBrush.GradientStops>
            <GradientStop Color="Blue" Offset="0.0" />
            <GradientStop Color="Red" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="LimeGreen" Offset="1" />
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

    <Rectangle Width="200" Height="100" Margin="10">
      <Rectangle.Fill>

        <!-- This gradient uses a ColorInterpolationMode of "SRgbLinearInterpolation"
             which indicates that the colors of the gradient are interpolated using the
             sRGB color space. -->
        <LinearGradientBrush ColorInterpolationMode="SRgbLinearInterpolation" 
        StartPoint="0,0.5" EndPoint="1,0.5">
          <LinearGradientBrush.GradientStops>
            <GradientStop Color="Blue" Offset="0.0" />
            <GradientStop Color="Red" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="LimeGreen" Offset="1" />
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

  </StackPanel>
</Page>

下圖顯示上述範例所產生的內容。

差補模式不同的兩種漸層

備註

相依性屬性資訊

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

適用於