コード例 #1
0
        protected override void OnConnected(UIElement newElement)
        {
            Compositor compositor = Window.Current.Compositor;

            // Create AmbientLight and set its properties
            AmbientLight ambientLight = compositor.CreateAmbientLight();

            ambientLight.Color = Colors.White;

            // Associate CompositionLight with XamlLight
            CompositionLight = ambientLight;

            // Add UIElement to the Light's Targets
            AmbLight.AddTargetElement(GetId(), newElement);
        }
コード例 #2
0
 protected override void OnDisconnected(UIElement oldElement)
 {
     // Dispose Light when it is removed from the tree
     AmbLight.RemoveTargetElement(GetId(), oldElement);
     CompositionLight.Dispose();
 }