UIElement.OpacityMask 属性

定义

获取或设置一个作为 Brush 实现的不透明蒙板,该蒙板可应用到此元素所呈现内容的任何 Alpha 通道蒙板。Gets or sets an opacity mask, as a Brush implementation that is applied to any alpha-channel masking for the rendered content of this element. 这是依赖项属性。This is a dependency property.

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

属性值

Brush

要用于不透明蒙板的画笔。The brush to use for opacity masking.

示例

以下标记示例显示了 ImageBrush 一个应用到另一个的不透明蒙板 ImageThe following markup example shows an ImageBrush opacity mask applied to another Image.

<!-- 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 通道值为提供的 BrushThis property only uses whatever the alpha channel value is for the supplied Brush. Brush呈现的内容 (红色、绿色或蓝色) 的其他通道将被忽略。The other channels of the Brush's rendered content (Red, Green, or Blue) are ignored.

此目的最常见的 BrushImageBrush ,可用于各种照片屏蔽技术(例如 vignette)。The most typical Brush for this purpose is an ImageBrush, which can be used for a variety of photo masking techniques such as a vignette. Brush 可以使用任何定义的 (如 LinearGradientBrush) 。But any defined Brush (such as LinearGradientBrush) can be used.

在中 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) ,此属性值可以使用特定于抽象类的每个实现的内联语法 BrushIn 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML), this property value can use an inline syntax that is specific to each implementation of the Brush abstract class. 有关详细信息,请参阅 采用纯色和渐变进行绘制概述For more information, see Painting with Solid Colors and Gradients Overview.

依赖项属性信息Dependency Property Information

标识符字段Identifier field OpacityMaskProperty
元数据属性设置为 trueMetadata properties set to true None

适用于

另请参阅