语言

UIElement.OpacityMask 属性

定义

获取或设置不透明度掩码,作为 Brush 应用于此元素呈现内容的任何 alpha 通道掩码的实现。 这是依赖项属性。

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

属性值

用于不透明度掩码的画笔。

示例

以下标记示例显示了应用于另一个ImageBrushImage的不透明度掩码。

<!-- 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>

注解

此属性仅使用提供的任何 alpha 通道值 Brush。 将忽略呈现内容(红色、绿色或蓝色)的其他通道 Brush

此目的最典型的 Brush 是一种 ImageBrush,可用于各种照片掩码技术,如 vignette。 但可以使用任何定义的 Brush (如 LinearGradientBrush) 。

在可扩展应用程序标记语言(XAML)中,此属性值可以使用特定于抽象类的每个实现的 Brush 内联语法。 有关详细信息,请参阅 “使用纯色和渐变绘制”概述

Dependency 属性信息

项目 价值
标识符字段 OpacityMaskProperty
元数据属性设置为 true None

适用于

另请参阅