Hide app preview from Alt-tab taskbar on Windows 10 Universal App Platform

I am developing an application, and I would like it when the user is in Tablet Mode and switches from one application to another to show a black screen when you press "alt + tab" and open applications are displayed. Instead of showing a screenshot of the "myTrip" application, I would like to show a black screen.

enter image description here

I know that for WPF we had ShowInTaskbar = false , but nothing like that in the Windows 10 Universal App Platform.

I have tried so far:

Window.Current.CoreWindow.VisibilityChanged += CoreWindow_VisibilityChanged;

  private void Current_VisibilityChanged(object sender, VisibilityChangedEventArgs e) { var parentGrid = RootPanel(); parentGrid.Visibility = e.Visible ? Visibility.Visible : Visibility.Collapsed; } 

But the application snapshot is taken before these events are called. Any idea on how to do this?

Sincerely.

+8
c # win-universal-app windows-10-universal
source share
1 answer

I don’t understand why exactly you want to do this, but here it is.

You need to handle the Activated event of the current thread, and not take control of your content. See the example below.

First, XAML:

 <Canvas Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" > <Canvas x:Name="contetProtector" Canvas.ZIndex="10" Background="Black" Width="1014" Height="758" Visibility="Collapsed"/> <TextBlock Text="My precious content" FontSize="50" Canvas.Top="50" Canvas.Left="50"/> <TextBlock Text="Nobody should see it" FontSize="50" Canvas.Top="100" Canvas.Left="50"/> </Canvas> 

Then, codebehind the page:

 public MainPage() { this.InitializeComponent(); CoreWindow.GetForCurrentThread().Activated += CoreWindowOnActivated; } private void CoreWindowOnActivated(CoreWindow sender, WindowActivatedEventArgs args) { if(args.WindowActivationState == CoreWindowActivationState.Deactivated) this.contetProtector.Visibility = Visibility.Visible; else this.contetProtector.Visibility = Visibility.Collapsed; } 

Here you can see the unprotected / active screen and here is protected.

Hope this helps.

+2
source share

All Articles