In Windows Creaters Update, you can set the Gaussian blur to the window, just a few lines of code!
<GridLoaded= "grid_loaded"> <Gridx:name= "mg"></Grid> <GridBackground= "Blue"Opacity= "0.4"x:name= "Rootgrid" ></Grid> <!--your uielements - </Grid>
Windows.UI.Composition.Compositor _compositor; Windows.UI.Composition.SpriteVisual _hostsprite; PublicMainPage () { This. InitializeComponent (); _compositor= Windows.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual ( This). compositor; } Private voidGrid_loaded (Objectsender, RoutedEventArgs e) {_hostsprite=_compositor. Createspritevisual (); _hostsprite.size=NewSystem.Numerics.Vector2 ((float) Rootgrid.actualwidth, (float) rootgrid.actualheight); Elementcompositionpreview.setelementchildvisual (Mg, _hostsprite); _hostsprite.brush=_compositor. Createhostbackdropbrush (); }
Effect
The color of the grid in XAML can be changed, and it's OK to delete it. That is to achieve a specific color blur to the Start menu.
However, this method is not valid in the newly added PIP mode
about how to implement a PIP is actually very simple.
Detect if PIP is supported
Applicationview.getforcurrentview (). Isviewmodesupported (Applicationviewmode.compactoverlay)
into the picture
BOOL await Applicationview.getforcurrentview (). Tryenterviewmodeasync (Applicationviewmode.compactoverlay);
Viewmodepreferences compactoptions = viewmodepreferences.createdefault (applicationviewmode.compactoverlay); New Windows.Foundation.Size;//You want the window size boolawait Applicationview.getforcurrentview (). Tryenterviewmodeasync (Applicationviewmode.default, compactoptions);
Exit picture-in-pictures
BOOL await Applicationview.getforcurrentview (). Tryenterviewmodeasync (Applicationviewmode.default);
You can also combine the multi-window capabilities of the UWP
awaitCoreapplication.createnewview (). Dispatcher.runasync (Coredispatcherpriority.normal, () = { varframe =NewFrame (); Compactviewid=Applicationview.getforcurrentview (). Id; Frame. Navigate (typeof(Secondarycompactviewpage)); Window.Current.Content=frame; Window.Current.Activate (); Applicationview.getforcurrentview (). Title="picture in the picture window"; }); BOOLViewshown =awaitApplicationviewswitcher.tryshowasviewmodeasync (Compactviewid, Applicationviewmode.compactoverlay);
Microsoft's multi-window example: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews
Microsoft's introduction to PIP Features: https://blogs.msdn.microsoft.com/universal-windows-app-model/2017/02/11/ Compactoverlay-mode-aka-picture-in-picture/
I have also made a complete example that can be downloaded here Https://git.oschina.net/PixeezPlus/Sharp2DDemo/tree/master/GaussianBlurWindow
It is also important to note that this code is only valid for the Creaters update version of the PC
Windows creaters Update new Features-pip mode and window Gaussian blur