Add a WPF Application to Windows Taskbar

僤鯓⒐⒋嵵緔 提交于 2019-12-05 06:23:02

问题


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.

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.

The requirement that I have

  1. Dock the application to the taskbar.
  2. Show some status information.
  3. Show progress information.

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.

Regards Avik Sen


回答1:


You can do it like below....

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>

And Button click events

        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>

and Status info in...

  <TaskbarItemInfo.Description></TaskbarItemInfo.Description>


来源:https://stackoverflow.com/questions/21925772/add-a-wpf-application-to-windows-taskbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!