Windows creaters Update new Features-pip mode and window Gaussian blur

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.