ContainerVisual 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
可视化树中可以具有子级的节点。
[WebHostHidden]
public ref class ContainerVisual : Visual
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[WebHostHidden]
class ContainerVisual : Visual
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
[WebHostHidden]
class ContainerVisual : Visual
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class ContainerVisual : Visual
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public class ContainerVisual : Visual
Public Class ContainerVisual
Inherits Visual
- 继承
- 派生
- 属性
示例
// RootGrid is a XAML Grid element.
Compositor compositor = ElementCompositionPreview.GetElementVisual(RootGrid).Compositor;
ContainerVisual root = compositor.CreateContainerVisual();
SpriteVisual child = compositor.CreateSpriteVisual();
child.Brush = compositor.CreateColorBrush(Color.FromArgb(0xFF, 0x00, 0xCC, 0x00));
child.Offset = new Vector2(50.0f, 50.0f);
child.Size = new Vector2(200, 200);
root.Children.InsertAtTop(child);
// App.cpp
struct SampleApp : implements<SampleApp, IFrameworkViewSource, IFrameworkView>
{
...
void SetWindow(CoreWindow const& /* window */)
{
// Set up Composition.
m_compositor = Compositor{};
m_target = m_compositor.CreateTargetForCurrentView();
m_root = m_compositor.CreateContainerVisual();
m_target.Root(m_root);
// Create a simple scene.
auto child{ m_compositor.CreateSpriteVisual() };
child.Brush(m_compositor.CreateColorBrush(ColorHelper::FromArgb(0xFF, 0x00, 0xCC, 0x00)));
child.Offset({ 50.f, 50.f, 0.f });
child.Size({ 200.f, 200.f });
m_root.Children().InsertAtTop(child);
}
private:
Compositor m_compositor{ nullptr };
CompositionTarget m_target{ nullptr };
ContainerVisual m_root{nullptr};
};
属性
| 名称 | 说明 |
|---|---|
| AnchorPoint |
要放置在视觉对象的偏移量处的视觉对象上的点。 值根据视觉对象的大小进行规范化。 可动画处理。 (继承自 Visual) |
| BackfaceVisibility |
指定在 3D 转换期间视觉对象的背面是否应可见。 (继承自 Visual) |
| BorderMode |
指定如何组合与视觉对象关联的位图和剪辑的边缘,或与此视觉对象关联的子树中的所有视觉对象。 在父视觉对象处设置 BorderMode 将影响子树中的所有子视觉对象,并且可以在每个子视觉对象上选择性地关闭。 (继承自 Visual) |
| CenterPoint |
发生旋转或缩放的点。 可动画处理 (继承自 Visual) |
| Children |
ContainerVisual 的子级。 |
| Clip |
指定视觉对象的剪辑区域。 呈现视觉对象时,仅显示位于剪辑区域中的视觉对象部分,而扩展在剪辑区域外部的任何内容将被剪裁(即不显示)。 (继承自 Visual) |
| Comment |
要与 CompositionObject 关联的字符串。 (继承自 CompositionObject) |
| CompositeMode |
指定视觉对象的位图如何与屏幕混合。 (继承自 Visual) |
| Compositor |
用于创建此 CompositionObject 的 Compositor。 (继承自 CompositionObject) |
| DispatcherQueue |
获取 CompositionObject 的 DispatcherQueue。 (继承自 CompositionObject) |
| ImplicitAnimations |
附加到此对象的隐式动画的集合。 (继承自 CompositionObject) |
| IsHitTestVisible |
获取或设置一个值,该值指示位于此视觉对象的可视化子树是否参与命中测试。 (继承自 Visual) |
| IsPixelSnappingEnabled |
获取或设置一个值,该值指示合成引擎是否将呈现的视觉对象与像素边界对齐。 (继承自 Visual) |
| IsVisible |
指示视觉对象及其子视觉对象的整个子树是否可见。 (继承自 Visual) |
| Offset |
视觉对象相对于其父视觉对象的偏移量或根视觉对象的偏移量相对于承载视觉对象的窗口左上角的偏移量。 可动画处理。 (继承自 Visual) |
| Opacity |
视觉对象的不透明度。 可动画处理。 不透明度属性确定视觉对象的透明度(如果有)且值为 0 到 1。 0 完全透明,1 表示完全不透明。 具有不透明度属性 0 的视觉对象仍存在于树中。 与视觉对象上的其他属性一样,Opacity 可以使用 Windows,UI 进行动画处理。合成动画系统。 (继承自 Visual) |
| Orientation |
描述将应用于视觉对象的三维空间中的方向和旋转的四元数。 可动画处理。 (继承自 Visual) |
| Parent |
视觉对象的父级。 (继承自 Visual) |
| ParentForTransform |
指定此视觉对象的坐标系的视觉对象。 (继承自 Visual) |
| Properties |
与 CompositionObject 关联的属性的集合。 (继承自 CompositionObject) |
| RelativeOffsetAdjustment |
指定视觉对象相对于其父视觉对象的大小的偏移量。 (继承自 Visual) |
| RelativeSizeAdjustment |
获取或设置视觉对象相对于其父视觉对象的大小的大小。 (继承自 Visual) |
| RotationAngle |
视觉对象的旋转角度(弧度)。 可动画处理。 (继承自 Visual) |
| RotationAngleInDegrees |
视觉对象的旋转角度(以度为单位)。 可动画处理。 (继承自 Visual) |
| RotationAxis |
要旋转视觉对象的轴。 可动画处理。 (继承自 Visual) |
| Scale |
要应用于视觉对象的缩放。 (继承自 Visual) |
| Size |
视觉对象的宽度和高度。 可动画处理。 (继承自 Visual) |
| TransformMatrix |
要应用于视觉对象的转换矩阵。 可动画处理。 (继承自 Visual) |
方法
| 名称 | 说明 |
|---|---|
| Close() |
关闭 CompositionObject 并释放系统资源。 (继承自 CompositionObject) |
| Dispose() |
执行与释放、释放或重置非托管资源关联的应用程序定义任务。 (继承自 CompositionObject) |
| PopulatePropertyInfo(String, AnimationPropertyInfo) |
定义可以进行动画处理的属性。 (继承自 CompositionObject) |
| StartAnimation(String, CompositionAnimation, AnimationController) |
将动画与对象的指定属性连接,并启动动画。 (继承自 CompositionObject) |
| StartAnimation(String, CompositionAnimation) |
将动画与对象的指定属性连接,并启动动画。 (继承自 CompositionObject) |
| StartAnimationGroup(ICompositionAnimationBase) |
启动动画组。 CompositionObject 上的 StartAnimationGroup 方法允许启动 CompositionAnimationGroup。 组中的所有动画将在对象上同时启动。 (继承自 CompositionObject) |
| StopAnimation(String) |
断开与指定属性的动画的连接,并停止动画。 (继承自 CompositionObject) |
| StopAnimationGroup(ICompositionAnimationBase) |
停止动画组。 (继承自 CompositionObject) |
| TryGetAnimationController(String) |
返回指定属性上运行的动画的 AnimationController。 (继承自 CompositionObject) |