WPF / XAML TaskbarItemInfo:如何删除 ThumbButtons 的空白区域?

WPF / XAML TaskbarItemInfo : how to remove blank area for ThumbButtons?

我正在使用 Window.TaskbarItemInfo 来设置叠加图标和显示进度状态。这很好用,但是,即使我没有设置 ThumbButtons,缩略图下方显示的那些按钮仍然有一个空白区域。

我可以轻松添加按钮,但不能折叠该区域。我尝试将 ThumbButtonInfos 属性 显式设置为 null 或空集合。有什么想法吗?

我认为使用提供的 WPF 是不可能的 TaskbarItemInfo

我会查看 Microsoft 创建的名为 WindowsAPICodePack 的包。

您必须为此安装 this and this

加载 window 后,您可以通过 Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager class 设置覆盖图标和进度状态。示例:

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
    var bitmap = new Bitmap("d:\icon.png"); // or get it from resource
    var iconHandle = bitmap.GetHicon();
    var icon = System.Drawing.Icon.FromHandle(iconHandle);

    TaskbarManager.Instance.SetOverlayIcon(this, icon, "Accessibility Text");
    TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Indeterminate, this);
}

结果:

您可以看到我设置了叠加层和进度条,但缩略图下方没有空白按钮面板。