将 WPF 应用程序添加到 Windows 任务栏 [英] Add a WPF Application to Windows Taskbar

查看:45
本文介绍了将 WPF 应用程序添加到 Windows 任务栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的 WPF 应用程序停靠在 Windows 任务栏中,就像某些工具栏一样,地址在 Windows 7 中可用,WMP 在 Win XP 中可用.

I want to dock my WPF application in Windows TaskBar, just like some toolbars like Address works in Windows 7 and WMP works in Win XP.

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

The WPF app to have a set of 2-3 buttons which the user can directly go ahead and click to do the corresponding operation. I have done some R&D and found about TaskbarItemInfo class. But this does not help the full purpose as the application does not come in the task bar and user has to hover mouse over the minimized icon to get the thumbnail icons and click.

我的要求

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

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

There would be 2-3 buttons in the app, thus I want it to dock to taskbar so that user can directly click on it.

问候阿维克森

推荐答案

你可以像下面这样....

You can do it like below....

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

The ThumbButtonInfo also allows to set you Image and on Click you can invoke functionality

<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");
        }

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

You can show progress info in...

    <TaskbarItemInfo.ProgressValue></TaskbarItemInfo.ProgressValue>

和状态信息...

  <TaskbarItemInfo.Description></TaskbarItemInfo.Description>

这篇关于将 WPF 应用程序添加到 Windows 任务栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆