VisualBrush Class

Definition

使用 Visual 绘制区域。Paints an area with a Visual.

public ref class VisualBrush sealed : System::Windows::Media::TileBrush
public sealed class VisualBrush : System.Windows.Media.TileBrush
type VisualBrush = class
    inherit TileBrush
Public NotInheritable Class VisualBrush
Inherits TileBrush
Inheritance

Remarks

可以通过两种方法指定 VisualBrushVisual 内容。There are two ways to specify the Visual content of a VisualBrush.

  • 创建新 Visual,并使用它来设置 VisualBrushVisual 属性。Create a new Visual and use it to set the Visual property of the VisualBrush.

  • 使用现有 Visual创建目标 Visual的复制映像。Use an existing Visual, which creates a duplicate image of the target Visual. 然后,可以使用 VisualBrush 创建有趣的效果,如反射和放大。You can then use the VisualBrush to create interesting effects, such as reflection and magnification.

VisualBrush 定义新的 Visual 并且 VisualUIElement (如面板或控件)时,当 UIElement 属性设置为 AutoLayoutContent 时,布局系统将在 true及其子元素上运行。When you define a new Visual for a VisualBrush and that Visual is a UIElement (such as a panel or control), the layout system runs on the UIElement and its child elements when the AutoLayoutContent property is set to true. 不过,根 UIElement 本质上与系统的其余部分隔离;样式、情节提要和外部布局不能渗透此边界。However, the root UIElement is essentially isolated from the rest of the system; styles, storyboards, and external layout can't permeate this boundary. 因此,您应显式指定根 UIElement的大小,因为其唯一父级是 VisualBrush,因此它无法自动调整其大小,使其不会自动调整为正在绘制的区域。Therefore, you should explicitly specify the size of the root UIElement, because its only parent is the VisualBrush and therefore it cannot automatically size itself to the area being painted. 有关 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 中的布局的更多信息,请参阅布局For more information about layout in Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF), see the Layout.

如果 BitmapEffect 位于画笔的父链中,则对 VisualBrush 的可视化树的更新将不会传播。Updates to the visual tree of a VisualBrush will not propagate if a BitmapEffect is in the brush's parent chain. 您可以通过对超出效果的对象强制更新场景来解决此限制。You can workaround this limitation by forcing an update of the scene on the object above the effect. 可以调用 InvalidateVisual 或包含动画来强制场景更新。You can call InvalidateVisual or include an animation to force a scene update.

冻结功能: 因为它继承自 Freezable 类,所以 VisualBrush 类提供若干特殊功能: VisualBrush 对象可以声明为,也可以在多个对象之间共享。Freezable Features: Because it inherits from the Freezable class, the VisualBrush class provides several special features: VisualBrush objects can be declared as and shared among multiple objects. 有关 Freezable 对象提供的不同功能的详细信息,请参阅可冻结对象概述For more information about the different features provided by Freezable objects, see the Freezable Objects Overview.

Note

VisualBrushVisual 属性设置为除以外的任何值时,无法将其设为只读(冻结) null.A VisualBrush cannot be made read-only (frozen) when its Visual property is set to any value other than null.

Constructors

VisualBrush()

初始化 VisualBrush 类的新实例。Initializes a new instance of the VisualBrush class.

VisualBrush(Visual)

初始化包含指定 VisualVisualBrush 类的一个新实例。Initializes a new instance of the VisualBrush class that contains the specified Visual.

Fields

AutoLayoutContentProperty

标识 AutoLayoutContent 依赖项属性。Identifies the AutoLayoutContent dependency property.

VisualProperty

标识 Visual 依赖项属性。Identifies the Visual dependency property.

Properties

AlignmentX

获取或设置 TileBrush 基本磁贴中内容的水平对齐方式。Gets or sets the horizontal alignment of content in the TileBrush base tile.

(Inherited from TileBrush)
AlignmentY

获取或设置 TileBrush 基本图块中内容的垂直对齐方式。Gets or sets the vertical alignment of content in the TileBrush base tile.

(Inherited from TileBrush)
AutoLayoutContent

获取或设置一个值,该值指定此 VisualBrush 是否将在其 Visual 上运行布局。Gets or sets a value that specifies whether this VisualBrush will run layout its Visual.

CanFreeze

获取一个值,该值指示是否可将对象变为不可修改。Gets a value that indicates whether the object can be made unmodifiable.

(Inherited from Freezable)
DependencyObjectType

获取对此实例的 CLRCLR 类型进行包装的 DependencyObjectTypeGets the DependencyObjectType that wraps the CLRCLR type of this instance.

(Inherited from DependencyObject)
Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
HasAnimatedProperties

获取一个值,该值指示一个或多个 AnimationClock 对象是否与此对象的任何依赖项属性相关联。Gets a value that indicates whether one or more AnimationClock objects is associated with any of this object's dependency properties.

(Inherited from Animatable)
IsFrozen

获取一个值,该值指示对象当前是否可修改。Gets a value that indicates whether the object is currently modifiable.

(Inherited from Freezable)
IsSealed

获取一个值,该值指示此实例当前是否为密封的(只读)。Gets a value that indicates whether this instance is currently sealed (read-only).

(Inherited from DependencyObject)
Opacity

获取或设置 Brush 的不透明度。Gets or sets the degree of opacity of a Brush.

(Inherited from Brush)
RelativeTransform

获取或设置使用相对坐标应用到画笔的转换。Gets or sets the transformation that is applied to the brush using relative coordinates.

(Inherited from Brush)
Stretch

获取或设置一个值,它指定此 TileBrush 的内容如何拉伸才适合其磁贴。Gets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles.

(Inherited from TileBrush)
TileMode

获取或设置一个值,该值指定在基本图块小于输出区时 TileBrush 如何填充你正在绘画的区域。Gets or sets a value that specifies how a TileBrush fills the area that you are painting if the base tile is smaller than the output area.

(Inherited from TileBrush)
Transform

获取或设置应用于画笔的转换。Gets or sets the transformation that is applied to the brush. 此转换在完成画笔输出的映射和定位后应用。This transformation is applied after the brush's output has been mapped and positioned.

(Inherited from Brush)
Viewbox

获取或设置 TileBrush 图块中内容的位置和尺寸。Gets or sets the position and dimensions of the content in a TileBrush tile.

(Inherited from TileBrush)
ViewboxUnits

获取或设置一个值,该值指定 Viewbox 值是相对于 TileBrush 内容的边界框而言,还是绝对值。Gets or sets a value that specifies whether the Viewbox value is relative to the bounding box of the TileBrush contents or whether the value is absolute.

(Inherited from TileBrush)
Viewport

获取或设置 TileBrush 的基本图块的位置和尺寸。Gets or sets the position and dimensions of the base tile for a TileBrush.

(Inherited from TileBrush)
ViewportUnits

获取或设置 BrushMappingMode 枚举,该枚举指定 Viewport 的值(该值指示 TileBrush 基本图块的大小和位置)是否是相对于输出区域的大小。Gets or sets a BrushMappingMode enumeration that specifies whether the value of the Viewport, which indicates the size and position of the TileBrush base tile, is relative to the size of the output area.

(Inherited from TileBrush)
Visual

获取或设置画笔的内容。Gets or sets the brush's content.

Methods

ApplyAnimationClock(DependencyProperty, AnimationClock)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用 SnapshotAndReplace 切换行为。If the property is already animated, the SnapshotAndReplace handoff behavior is used.

(Inherited from Animatable)
ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用指定的 HandoffBehaviorIf the property is already animated, the specified HandoffBehavior is used.

(Inherited from Animatable)
BeginAnimation(DependencyProperty, AnimationTimeline)

将动画应用于指定 DependencyPropertyApplies an animation to the specified DependencyProperty. 动画会在呈现下一帧时启动。The animation is started when the next frame is rendered. 如果指定属性已进行动画处理,则使用 SnapshotAndReplace 切换行为。If the specified property is already animated, the SnapshotAndReplace handoff behavior is used.

(Inherited from Animatable)
BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

将动画应用于指定 DependencyPropertyApplies an animation to the specified DependencyProperty. 动画会在呈现下一帧时启动。The animation is started when the next frame is rendered. 如果指定的属性已进行动画处理,则使用指定的 HandoffBehaviorIf the specified property is already animated, the specified HandoffBehavior is used.

(Inherited from Animatable)
CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
ClearValue(DependencyProperty)

清除属性的本地值。Clears the local value of a property. 要清除的属性由 DependencyProperty 标识符指定。The property to be cleared is specified by a DependencyProperty identifier.

(Inherited from DependencyObject)
ClearValue(DependencyPropertyKey)

清除只读属性的本地值。Clears the local value of a read-only property. 要清除的属性由 DependencyPropertyKey 指定。The property to be cleared is specified by a DependencyPropertyKey.

(Inherited from DependencyObject)
Clone()

创建此 VisualBrush 的可修改克隆,从而深度复制此对象的值。Creates a modifiable clone of this VisualBrush, making deep copies of this object's values.

CloneCore(Freezable)

使用基(未经过动画处理的)属性值使该实例成为指定 Freezable 的克隆(深层复制)。Makes the instance a clone (deep copy) of the specified Freezable using base (non-animated) property values.

(Inherited from Freezable)
CloneCurrentValue()

创建此 VisualBrush 对象的可修改复本,从而深度复制此对象的当前值。Creates a modifiable clone of this VisualBrush object, making deep copies of this object's current values. 不复制资源引用、数据绑定和动画,而是复制其当前值。Resource references, data bindings, and animations are not copied, but their current values are.

CloneCurrentValueCore(Freezable)

使用当前属性值使该实例成为指定 Freezable 的可修改克隆(深层复制)。Makes the instance a modifiable clone (deep copy) of the specified Freezable using current property values.

(Inherited from Freezable)
CoerceValue(DependencyProperty)

对指定依赖属性的值进行强制。Coerces the value of the specified dependency property. 通过对调用方 DependencyObject 上存在的依赖属性的属性元数据中所指定的任何 CoerceValueCallback 函数进行调用来完成此操作。This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.

(Inherited from DependencyObject)
CreateInstance()

初始化 Freezable 类的新实例。Initializes a new instance of the Freezable class.

(Inherited from Freezable)
CreateInstanceCore()

在派生类中实现时,创建 Freezable 派生类的新实例。When implemented in a derived class, creates a new instance of the Freezable derived class.

(Inherited from Freezable)
Equals(Object)

确定提供的 DependencyObject 是否等效于当前 DependencyObjectDetermines whether a provided DependencyObject is equivalent to the current DependencyObject.

(Inherited from DependencyObject)
Freeze()

使当前对象不可修改,并且将其 IsFrozen 属性设置为 trueMakes the current object unmodifiable and sets its IsFrozen property to true.

(Inherited from Freezable)
FreezeCore(Boolean)

使此 Animatable 对象成为不可修改的对象,或确定是否可使其成为不可修改的对象。Makes this Animatable object unmodifiable or determines whether it can be made unmodifiable.

(Inherited from Animatable)
GetAnimationBaseValue(DependencyProperty)

返回指定的 DependencyProperty 的未经过动画处理的值。Returns the non-animated value of the specified DependencyProperty.

(Inherited from Animatable)
GetAsFrozen()

使用基(未经过动画处理的)属性值创建 Freezable 的冻结副本。Creates a frozen copy of the Freezable, using base (non-animated) property values. 由于副本已冻结,因此将通过引用复制任何冻结的子对象。Because the copy is frozen, any frozen sub-objects are copied by reference.

(Inherited from Freezable)
GetAsFrozenCore(Freezable)

让该实例成为指定的 Freezable 的冻结克隆,前者使用基(非动画的)属性值。Makes the instance a frozen clone of the specified Freezable using base (non-animated) property values.

(Inherited from Freezable)
GetContentBounds(Rect)

获取 TileBrush 内容的当前边界。Obtains the current bounds of the TileBrush content.

(Inherited from TileBrush)
GetCurrentValueAsFrozen()

使用当前属性值创建 Freezable 的冻结副本。Creates a frozen copy of the Freezable using current property values. 由于副本已冻结,因此将通过引用复制任何冻结的子对象。Because the copy is frozen, any frozen sub-objects are copied by reference.

(Inherited from Freezable)
GetCurrentValueAsFrozenCore(Freezable)

使当前实例成为指定 Freezable 的冻结克隆。Makes the current instance a frozen clone of the specified Freezable. 如果对象具有动画依赖属性,则复制其当前的动画值。If the object has animated dependency properties, their current animated values are copied.

(Inherited from Freezable)
GetHashCode()

获取此 DependencyObject 的哈希代码。Gets a hash code for this DependencyObject.

(Inherited from DependencyObject)
GetLocalValueEnumerator()

创建一个专用的枚举数,用于确定哪些依赖项属性在此 DependencyObject 上具有以本地方式设置的值。Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

(Inherited from DependencyObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetValue(DependencyProperty)

DependencyObject 的此实例返回依赖属性的当前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

(Inherited from DependencyObject)
InvalidateProperty(DependencyProperty)

重新评估指定依赖属性的有效值。Re-evaluates the effective value for the specified dependency property.

(Inherited from DependencyObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
OnChanged()

修改当前 Freezable 对象时调用。Called when the current Freezable object is modified.

(Inherited from Freezable)
OnFreezablePropertyChanged(DependencyObject, DependencyObject)

确保为刚刚设置的 DependencyObjectType 数据成员建立适当的上下文指针。Ensures that appropriate context pointers are established for a DependencyObjectType data member that has just been set.

(Inherited from Freezable)
OnFreezablePropertyChanged(DependencyObject, DependencyObject, DependencyProperty)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code.

(Inherited from Freezable)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

重写 OnPropertyChanged(DependencyPropertyChangedEventArgs)DependencyObject 实现,以同时调用任何响应类型 Freezable 不断变化的依赖属性的 Changed 处理程序。Overrides the DependencyObject implementation of OnPropertyChanged(DependencyPropertyChangedEventArgs) to also invoke any Changed handlers in response to a changing dependency property of type Freezable.

(Inherited from Freezable)
ReadLocalValue(DependencyProperty)

如果存在,则返回依赖属性的本地值。Returns the local value of a dependency property, if it exists.

(Inherited from DependencyObject)
ReadPreamble()

确保正在从有效的线程访问 FreezableEnsures that the Freezable is being accessed from a valid thread. Freezable 的继承者必须在任何 API 一开始读取不属于依赖项对象的数据成员时调用此方法。Inheritors of Freezable must call this method at the beginning of any API that reads data members that are not dependency properties.

(Inherited from Freezable)
SetCurrentValue(DependencyProperty, Object)

设置依赖属性的值而不更改其值源。Sets the value of a dependency property without changing its value source.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object)

设置依赖属性的本地值,该值由其依赖属性标识符指定。Sets the local value of a dependency property, specified by its dependency property identifier.

(Inherited from DependencyObject)
SetValue(DependencyPropertyKey, Object)

设置一个只读依赖属性的本地值,该值由依赖属性的 DependencyPropertyKey 标识符指定。Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.

(Inherited from DependencyObject)
ShouldSerializeProperty(DependencyProperty)

返回一个值,该值指示序列化进程是否应序列化所提供的依赖属性的值。Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.

(Inherited from DependencyObject)
ToString()

返回此 Brush 的字符串表示形式。Return string representation of this Brush.

(Inherited from Brush)
ToString(IFormatProvider)

基于指定的区域性特定格式设置信息创建此对象的字符串表示形式。Creates a string representation of this object based on the specified culture-specific formatting information.

(Inherited from Brush)
VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
WritePostscript()

引发 FreezableChanged 事件并调用其 OnChanged() 方法。Raises the Changed event for the Freezable and invokes its OnChanged() method. Freezable 派生的类应在修改的类成员不存储为依赖属性的任何 API 的末尾调用此方法。Classes that derive from Freezable should call this method at the end of any API that modifies class members that are not stored as dependency properties.

(Inherited from Freezable)
WritePreamble()

验证 Freezable 是否未被冻结,并且是否正在从有效的线程上下文中访问它。Verifies that the Freezable is not frozen and that it is being accessed from a valid threading context. Freezable 的继承项应当在任何 API 一开始写入不属于依赖项属性的数据成员时调用此方法。Freezable inheritors should call this method at the beginning of any API that writes to data members that are not dependency properties.

(Inherited from Freezable)

Events

Changed

在修改 Freezable 或其包含的对象时发生。Occurs when the Freezable or an object it contains is modified.

(Inherited from Freezable)

Explicit Interface Implementations

IFormattable.ToString(String, IFormatProvider)

使用指定格式对当前实例的值设置格式。Formats the value of the current instance using the specified format.

(Inherited from Brush)

Applies to

See also