在 Windows 10 的 TaskView 中停止 UWP 应用程序的屏幕捕获

Stop screen capture on UWP app in TaskView of Windows 10

我通过

停止了 UWP 应用程序的屏幕捕获
ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false;

但是,该应用程序仍会在 Windows10 的任务视图中显示其预览

谁能告诉我如何在任务视图中禁用应用程序预览

这是当前的TaskView

这就是我所需要的

捕获应用程序的缩略图看起来像是一种系统行为,我不知道如何禁用它。

但由于捕获仅在用户按下 Alt+Tab 或单击任务栏上的任务切换按钮时发生,因此有机会在系统截屏之前用覆盖层覆盖应用程序应用

首先添加一个不透明的叠加层,并将其初始可见性设置为Collapsed

<Grid>
    <TextBlock FontSize="50" Text="Your controls here!" />
    <Grid Background="Black" x:Name="overlay" Visibility="Collapsed" />
</Grid>

然后为应用 window 的 Activated 事件注册处理程序,

Window.Current.Activated += Current_Activated;

Display/Hidewindow为deactivated/activated、

时的叠加
private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
{
    if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
    {
        overlay.Visibility = Visibility.Visible;
    }
    else
    {
        overlay.Visibility = Visibility.Collapsed;
    }
}