LayerVisual クラス

定義

子が 1 つのレイヤーにフラット化される ContainerVisual。

public ref class LayerVisual sealed : ContainerVisual
/// [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)]
class LayerVisual final : ContainerVisual
/// [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)]
class LayerVisual final : ContainerVisual
[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 sealed class LayerVisual : ContainerVisual
[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 sealed class LayerVisual : ContainerVisual
Public NotInheritable Class LayerVisual
Inherits ContainerVisual
継承
Object Platform::Object IInspectable CompositionObject Visual ContainerVisual LayerVisual
属性

レイヤーに効果を適用するVisual

private async void InitComposition()
{
  Compositor compositor = ElementCompositionPreview.GetElementVisual(MyGrid).Compositor;

  //Create LayerVisual
  LayerVisual layerVisual = compositor.CreateLayerVisual();
  layerVisual.Size = new Vector2(900,900);

  //Create SpriteVisuals to use as LayerVisual child
  SpriteVisual sv1 = compositor.CreateSpriteVisual();
  sv1.Brush = compositor.CreateColorBrush(Windows.UI.Colors.Blue);
  sv1.Size = new Vector2(300, 300);
  sv1.Offset = new Vector3(200, 200, 0);

  SpriteVisual sv2 = compositor.CreateSpriteVisual();
  sv2.Brush = compositor.CreateColorBrush(Colors.Red);
  sv2.Size = new Vector2(300, 300);
  sv2.Offset = new Vector3(400, 400, 0);

  //Add children to the LayerVisual
  layerVisual.Children.InsertAtTop(sv1);
  layerVisual.Children.InsertAtTop(sv2);

  //Create Effect
  var graphicsEffect = new GaussianBlurEffect
  {
     Name = "Blur",
     Source = new CompositionEffectSourceParameter("Backdrop"),
     BlurAmount = 10.0f,
     BorderMode = EffectBorderMode.Hard,
     Optimization = EffectOptimization.Balanced
  };

  var blurEffectFactory = compositor.CreateEffectFactory(graphicsEffect,
      new[] { "Blur.BlurAmount" });
  var blurBrush = blurEffectFactory.CreateBrush();

  //Apply Effect
  layerVisual.Effect = blurBrush;

  ElementCompositionPreview.SetElementChildVisual(MyGrid, layerVisual);
}        

DropShadow を追加する

private async void InitComposition()
{
  Compositor compositor = ElementCompositionPreview.GetElementVisual(MyGrid).Compositor;

  //Create LayerVisual
  LayerVisual layerVisual = compositor.CreateLayerVisual();
  layerVisual.Size = new Vector2(900, 900);

  //Create SpriteVisuals to use as LayerVisual child
  SpriteVisual sv1 = compositor.CreateSpriteVisual();
  sv1.Brush = compositor.CreateColorBrush(Windows.UI.Colors.Blue);
  sv1.Size = new Vector2(300, 300);
  sv1.Offset = new Vector3(200, 200, 0);

  SpriteVisual sv2 = compositor.CreateSpriteVisual();
  sv2.Brush = compositor.CreateColorBrush(Colors.Red);
  sv2.Size = new Vector2(300, 300);
  sv2.Offset = new Vector3(400, 400, 0);

  //Add children to the LayerVisual
  layerVisual.Children.InsertAtTop(sv1);
  layerVisual.Children.InsertAtTop(sv2);

  //Create DropShadow
  DropShadow shadow = compositor.CreateDropShadow();
  shadow.Color = Colors.DarkSlateGray;
  shadow.Offset = new Vector3(40, 40, 0);
  shadow.BlurRadius = 9;
  shadow.SourcePolicy = CompositionDropShadowSourcePolicy.InheritFromVisualContent;

  //Associate Shadow with LayerVisual
  layerVisual.Shadow = shadow;

  ElementCompositionPreview.SetElementChildVisual(MyGrid, layerVisual);
}         

注釈

LayerVisual は、ビジュアルのツリーを選択するために使用できる特殊な入力型です。 ツリー入力は、LayerVisual を使用して暗黙的に指定されます。 EffectBrush が LayerVisual の Effect プロパティに設定されている場合、EffectBrush は LayerVisual にルート化されたサブツリーを入力として自動的に使用します。 LayerVisual の暗黙的な入力は、次のように効果に対して機能します。

  • 効果に 1 つの入力がある場合、EffectBrush は LayerVisual にルート化されたサブツリーを入力として使用します。
  • 効果に 2 つの入力がある場合、EffectBrush の最初の非連結入力では、LayerVisual でルート化されたサブツリーが入力として使用されます。
  • システムでは、0 個の入力または SurfaceBrush にバインドされているすべての入力を持つ効果を LayerVisual の Effect プロパティの EffectBrush として設定することはできません。 これにより、例外がスローされます。

プロパティ

AnchorPoint

ビジュアルのオフセットに配置されるビジュアル上のポイント。 値は、ビジュアルのサイズに関して正規化されます。 アニメーション化可能。

(継承元 Visual)
BackfaceVisibility

3D 変換中にビジュアルの背面を表示するかどうかを指定します。

(継承元 Visual)
BorderMode

ビジュアルに関連付けられたビットマップとクリップ、またはサブツリー内のすべてのビジュアルをこのビジュアルにルート化して、ビットマップとクリップのエッジを作成する方法を指定します。 親ビジュアルで BorderMode を設定すると、サブツリー内のすべての子ビジュアルに影響し、各子ビジュアルで選択的にオフにすることができます。

(継承元 Visual)
CenterPoint

回転またはスケーリングが発生するポイント。 アニメーション化可能

(継承元 Visual)
Children

ContainerVisual の子。

(継承元 ContainerVisual)
Clip

ビジュアルのクリッピング領域を指定します。 ビジュアルをレンダリングすると、クリッピング領域の内側にあるビジュアルの部分のみが表示され、クリッピング領域の外側に広がるコンテンツはクリップされます (つまり、表示されません)。

(継承元 Visual)
Comment

CompositionObject に関連付ける文字列。

(継承元 CompositionObject)
CompositeMode

ビジュアルのビットマップを画面とブレンドする方法を指定します。

(継承元 Visual)
Compositor

この CompositionObject の作成に使用するコンポジター

(継承元 CompositionObject)
DispatcherQueue

CompositionObject の DispatcherQueue を取得します。

(継承元 CompositionObject)
Effect

LayerVisual の子のフラット化表現に適用される効果。

ImplicitAnimations

このオブジェクトにアタッチされている暗黙的なアニメーションのコレクション。

(継承元 CompositionObject)
IsHitTestVisible

このビジュアルにルート化されたビジュアル サブツリーがヒット テストに参加するかどうかを示す値を取得または設定します。

(継承元 Visual)
IsPixelSnappingEnabled

コンポジション エンジンがレンダリングされたビジュアルをピクセル境界に合わせるかどうかを示す値を取得または設定します。

(継承元 Visual)
IsVisible

ビジュアルとその子ビジュアルのサブツリー全体が表示されるかどうかを示します。

(継承元 Visual)
Offset

親に対するビジュアルのオフセット、またはルート ビジュアルの場合は、ビジュアルをホストするウィンドウの左上隅からの相対オフセット。 アニメーション化可能。

(継承元 Visual)
Opacity

ビジュアルの不透明度。 アニメーション化可能。

opacity プロパティは、Visual の透明度 (存在する場合) を決定し、0 から 1 の値です。 0 は完全に透明で、1 は完全に不透明です。 Opacity プロパティが 0 のビジュアルは、ツリーにまだ存在します。 ビジュアルの他のプロパティと同様に、Opacity は Windows、UI を使用してアニメーション化できます。コンポジション アニメーション システム。

(継承元 Visual)
Orientation

ビジュアルに適用される 3D 空間の向きと回転を表す四元数。 アニメーション化可能。

(継承元 Visual)
Parent

ビジュアルの親。

(継承元 Visual)
ParentForTransform

このビジュアルを構成する座標系を指定するビジュアル。

(継承元 Visual)
Properties

CompositionObject に関連付けられているプロパティのコレクション。

(継承元 CompositionObject)
RelativeOffsetAdjustment

親ビジュアルのサイズに関するビジュアルのオフセットを指定します。

(継承元 Visual)
RelativeSizeAdjustment

親ビジュアルのサイズに関するビジュアルのサイズを取得または設定します。

(継承元 Visual)
RotationAngle

ビジュアルの回転角度 (ラジアン)。 アニメーション化可能。

(継承元 Visual)
RotationAngleInDegrees

ビジュアルの回転角度を度単位で指定します。 アニメーション化可能。

(継承元 Visual)
RotationAxis

ビジュアルを回転させる軸。 アニメーション化可能。

(継承元 Visual)
Scale

ビジュアルに適用するスケール。

(継承元 Visual)
Shadow

LayerVisual の子のフラット化された表現に適用される影。

Size

ビジュアルの幅と高さ。 アニメーション化可能。

(継承元 Visual)
TransformMatrix

ビジュアルに適用する変換マトリックス。 アニメーション化可能。

(継承元 Visual)

メソッド

Close()

CompositionObject を閉じ、システム リソースを解放します。

(継承元 CompositionObject)
Dispose()

アンマネージ リソースの解放またはリセットに関連付けられているアプリケーション定義のタスクを実行します。

(継承元 CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

アニメーション化できるプロパティを定義します。

(継承元 CompositionObject)
StartAnimation(String, CompositionAnimation)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

アニメーションをオブジェクトの指定したプロパティに接続し、アニメーションを開始します。

(継承元 CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

アニメーション グループを開始します。

CompositionObject の StartAnimationGroup メソッドを使用すると、CompositionAnimationGroup を開始できます。 グループ内のすべてのアニメーションは、オブジェクトで同時に開始されます。

(継承元 CompositionObject)
StopAnimation(String)

指定したプロパティからアニメーションを切断し、アニメーションを停止します。

(継承元 CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

アニメーション グループを停止します。

(継承元 CompositionObject)
TryGetAnimationController(String)

指定したプロパティで実行されているアニメーションの AnimationController を返します。

(継承元 CompositionObject)

適用対象

こちらもご覧ください