New Features of Windows 10 Creaters Update-image-in-painting mode and window Gaussian blur

Source: Internet
Author: User

New Features of Windows 10 Creaters Update-image-in-painting mode and window Gaussian blur

In Windows 10 Creaters Update, you can set Gaussian Blur for the window, just a few lines of code!

    <Grid   Loaded="Grid_Loaded">        <Grid x:Name="mg"></Grid>        <Grid Background="Blue" Opacity="0.4" x:Name="rootGrid" ></Grid>        <!--your uielements-->    </Grid>
        Windows.UI.Composition.Compositor _compositor;        Windows.UI.Composition.SpriteVisual _hostSprite;        public MainPage()        {            this.InitializeComponent();            _compositor = Windows.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual(this).Compositor;        }        private void Grid_Loaded(object sender, RoutedEventArgs e)        {            _hostSprite = _compositor.CreateSpriteVisual();            _hostSprite.Size = new System.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 deleted. That is to blur the specific color of the Start Menu.

However, this method does not work in the newly added image-in-picture mode.

It's actually very easy to learn how to implement in-picture

Check whether image-in-picture is supported

ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)

Go to painting

bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
ViewModePreferences compactOptions = ViewModePreferences. createDefault (ApplicationViewMode. compactOverlay); compactOptions. customSize = new Windows. foundation. size (320,200); // the Size of the window you want bool modeSwitched = await ApplicationView. getForCurrentView (). tryEnterViewModeAsync (ApplicationViewMode. default, compactOptions );

Exit from painting

bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);

You can also combine the UWP Multi-Window Function

Await CoreApplication. createNewView (). dispatcher. runAsync (CoreDispatcherPriority. normal, () => {var frame = new Frame (); compactViewId = ApplicationView. getForCurrentView (). id; frame. navigate (typeof (SecondaryCompactViewPage); Window. current. content = frame; Window. current. activate (); ApplicationView. getForCurrentView (). title = "painting window" ;}); bool viewShown = await ApplicationViewSwitcher. tryShowAsViewModeAsync (compactViewId, ApplicationViewMode. compactOverlay );

Microsoft multi-window example: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews

Introduction to the function of picture-in-picture: https://blogs.msdn.microsoft.com/universal-windows-app-model/2017/02/11/compactoverlay-mode-aka-picture-in-picture/

I also made a complete example where you can download the https://git.oschina.net/PixeezPlus/Sharp2DDemo/tree/master/GaussianBlurWindow here

Note that the code is only valid for the Creaters Update and later versions of the PC.

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.