UIElement.OpacityMask 屬性

定義

取得或設定套用至任何 Alpha 色板遮罩 (用來遮住此項目的呈現內容) 時實作 Brush 的不透明度遮罩。 這是相依性屬性。

C#
public System.Windows.Media.Brush OpacityMask { get; set; }

屬性值

Brush

用於不透明度遮罩的筆刷。

範例

下列標記範例顯示套用至另一個 ImageBrush Image 的不透明度遮罩。

XAML
<!-- With the Opacity Mask-->
<Image
  Height="150"
  Width="200"
  Source="sampleImages/Waterlilies.jpg"
  HorizontalAlignment="Left"
  Margin="10"
  Grid.Column="2" Grid.Row="1">
  <Image.OpacityMask>
    <ImageBrush ImageSource="sampleImages/tornedges.png"/>
  </Image.OpacityMask>
</Image>

備註

這個屬性只會針對提供的 Brush 使用任何 Alpha 色板值。 會忽略 所呈現內容的其他通道 Brush (紅色、綠色或藍色) 。

此用途最典型的 BrushImageBrush ,可用於各種相片遮罩技術,例如 vignette。 但是可以使用任何定義的 Brush (,例如 LinearGradientBrush) 。

在 Extensible Application Markup Language (XAML) 中,這個屬性值可以使用抽象類別每個實作 Brush 特有的內嵌語法。 如需詳細資訊,請參閱 使用純色和漸層繪製概觀

相依性屬性資訊

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

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另請參閱