संपादित करें

इसके माध्यम से साझा किया गया


VisualBrush.Visual Property

Definition

Gets or sets the brush's content.

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

Property Value

The brush's content. The default is null.

Remarks

There are two ways to specify the Visual content of a VisualBrush.

  • Create a new Visual and use it to set the Visual property of the VisualBrush.

  • Use an existing Visual, which creates a duplicate image of the target Visual. You can then use the VisualBrush to create interesting effects, such as reflection and magnification.

Visual is quite high in the overall WPF class hierarchy, so a very large number of objects could possibly serve as the visual that you use for a VisualBrush; the entire list cannot be shown here. See Visual; refer to the "Inheritance Hierarchy" section, which will show the immediately derived classes. You can then click on the immediately derived classes and traverse the hierarchies to get a sense of the full range of possibilities. At a top level, the two most common categories of objects you might use for a VisualBrush are UIElement or ContainerVisual. UIElement encompasses basically any UI element that can otherwise participate in the UI for a WPF application. ContainerVisual contains a DrawingGroup that includes one or more Drawing-derived objects.

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. However, the root UIElement is essentially isolated from the rest of the system; styles, storyboards, and external layout dictated by the parent where the brush is applied cannot permeate this boundary. 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. For more information about layout in Windows Presentation Foundation (WPF), see the Layout.

Updates to the visual tree of a VisualBrush will not propagate if a BitmapEffect is in the brush's parent chain. You can work around this limitation by forcing an update of the scene on the object above the effect. You can call InvalidateVisual or include an animation to force a scene update.

Note

A VisualBrush cannot be made read-only (frozen) when its Visual property is set to any value other than null.

XAML Property Element Usage

<object>
  <object.Visual>
    singleVisualRoot
  </object.Visual>
</object>

XAML Attribute Usage

<object Visual="{bindingExpression}"/>

-or-

<object Visual="{resourceExpression}"/>

XAML Values

singleVisualRoot A single object element that defines a new visual element for the brush. This must be an object that derives from Visual. See Remarks.

bindingExpression An expression that evaluates to an existing Visual instance.

resourceExpression A StaticResource or DynamicResource that evaluates to an existing Visual instance. See XAML Resources.

Dependency Property Information

Identifier field VisualProperty
Metadata properties set to true None

Applies to