【问题标题】:Add a WPF Application to Windows Taskbar将 WPF 应用程序添加到 Windows 任务栏
【发布时间】:2014-03-22 10:57:25
【问题描述】:

我想将我的 WPF 应用程序停靠在 Windows 任务栏中,就像一些工具栏(如 Address 在 Windows 7 中工作,WMP 在 Win XP 中工作)一样。

WPF 应用程序有一组 2-3 个按钮,用户可以直接点击这些按钮进行相应的操作。我做了一些研发,发现了 TaskbarItemInfo 类。但这无济于事,因为应用程序没有出现在任务栏中,用户必须将鼠标悬停在最小化图标上才能获得缩略图图标并单击。

我的要求

  1. 将应用程序停靠在任务栏上。
  2. 显示一些状态信息。
  3. 显示进度信息。

应用程序中会有 2-3 个按钮,因此我希望它停靠在任务栏上,以便用户可以直接单击它。

问候 阿维克森

【问题讨论】:

  • 我想你忘了问一个问题。
  • 我想知道它是如何实现的。
  • 如果我理解得很好 - 您希望 Windows Media Player 等按钮显示在任务栏中运行的应用程序的缩略图视图中吗?
  • @MilanRaval :正是我想要的。

标签: c# wpf taskbar


【解决方案1】:

你可以像下面那样做......

ThumbButtonInfo 还允许设置您的图像,点击时您可以调用功能

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication4" x:Class="WpfApplication4.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo>
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo Description="Play!" Click="ThumbButtonInfo_Click"/>
                <ThumbButtonInfo Description="Stop!" Click="ThumbButtonInfo_Click_1"  />
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    <Grid>
    </Grid>
</Window>

和按钮点击事件

        private void ThumbButtonInfo_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Clicked");
        }

        private void ThumbButtonInfo_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("Clicked");
        }

您可以在...中显示进度信息

    <TaskbarItemInfo.ProgressValue></TaskbarItemInfo.ProgressValue>

以及...中的状态信息

  <TaskbarItemInfo.Description></TaskbarItemInfo.Description>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-08
    • 2011-02-21
    • 2010-12-22
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 2010-11-04
    • 2010-12-27
    相关资源
    最近更新 更多