5

My aim is to place my application in the tray bar but I don't know how to do that for a WPF application ! (for a winform there is lots of docs but I don't find anything for Wpf)

Thanks

Orpheo
  • 386
  • 1
  • 6
  • 15
  • Does the app *only* exist in the tray, or is there a foreground component as well? – Matt Jul 05 '11 at 15:32
  • Also, look at this link, it may answer your question: http://stackoverflow.com/questions/995195/writing-a-windows-system-tray-application-with-net – Matt Jul 05 '11 at 15:32
  • no it's a normal application but i'd like to reduce it – Orpheo Jul 05 '11 at 15:57
  • I found that finally : http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/ I'm testing if it's work – Orpheo Jul 05 '11 at 15:58

2 Answers2

4

You could use this library for the tray icon, and to not have any windows you should remove any StartupUri that may be defined in the App class by default. Then you can override OnStartup to prepare any logic that your application should perform.

Not sure if you can assign a TaskbarIcon of this library directly to the application since it is normally used on Windows. But you can create a dummy popup to make it show up.

public TaskbarIcon MyTaskbarIcon { get; set; }

protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);
    Popup pu = new Popup();
    pu.Child = MyTaskbarIcon;
    //...
}

If you can have windows you can create a TaskbarIcon there and then you can call Hide() if you need it to completely disappear.

H.B.
  • 166,899
  • 29
  • 327
  • 400
0

After testing it, I recommand http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/

But be sure your icon is an an “Embedded Ressource” not “Ressource” in properties in Visual Studio.

Orpheo
  • 386
  • 1
  • 6
  • 15
  • Welcome to SO! If this is your answer, you probably want to click the check-mark to the left to mark it as complete :) – ewall Jul 06 '11 at 20:46
  • Thanks :) (I have to wait still 7 hours to validate my own answer ^^) – Orpheo Jul 07 '11 at 07:51