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.

示例

以下标记示例演示了一个应用于其他 ImageImageBrush 不透明蒙板。The 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>

注解

对于提供的 Brush,此属性只使用 alpha 通道值。This 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)中,此属性值可以使用特定于 Brush 抽象类的每个实现的内联语法。In 可扩展应用程序标记语言 (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 NoneNone

适用于

另请参阅