0

I am adding a LayerVisual to a Panel by invoking

LayerVisual layerVisual; // this is created using a Compositor in previous logic
Panel parent; // I get this Panel from my XAML
ElementCompositionPreview.SetElementChildVisual(parent, layerVisual);

Unfortunately using ElementCompositionPreview.SetElementChildVisual() I have two problems:

  1. I can set only one LayerVisual at a time
  2. such LayerVisual is placed on top of all the other elements (and I want instead it in the background)

Therefore, I would be happy to have a solution like

parent.Children.Insert(0, layerVisual);

but unfortunately the layerVisual is not an UIElement.

How can I achieve this result?

Cristiano Ghersi
  • 1,944
  • 1
  • 20
  • 46
  • I only see that you can add children to `layerVisual`. What's the effect that you want? – Bite Apr 01 '19 at 06:12
  • I want to add low level DropShadow to elements contained in a Canvas. For internal reasons I cannot use the DropShadowPanel provided by the UWP Toolkit. – Cristiano Ghersi Apr 01 '19 at 16:24
  • Have you checked the [Win2D Effect](https://github.com/Microsoft/Win2D)? – Timo Apr 02 '19 at 07:43
  • Thank you Timo for the hint, could you be a little bit more specific please? which effect are you referring to? – Cristiano Ghersi Apr 03 '19 at 05:21
  • The [ShadowEffect](http://microsoft.github.io/Win2D/html/T_Microsoft_Graphics_Canvas_Effects_ShadowEffect.htm). – Timo Apr 03 '19 at 08:59
  • Thank you Timo. Following your link, I can see there is a caveat: "Supported by Win2D but not Windows.UI.Composition.". Since we are using in several cases the Composition API, how can we deal with this dichotomy? Moreover, is there anyway a chance to set several LayerVisual elements as children of a Panel? – Cristiano Ghersi Apr 04 '19 at 00:36

0 Answers0