5

How can I minimize a Silverlight Out Of Browser application to windows system tray? Is it possible?

sri
  • 1,005
  • 1
  • 12
  • 26

4 Answers4

3

I like this question! It points to another obvious requirement that microsoft failed to support with OOB apps. Sadly this is not directly supported as part of existing Silverlight API. But having said that we could "explore" achieving this... (the tips below may / may not work as I myself have not tested them yet due to lack of Visual Studio environment currently on my machine!)

In a silverlight OOB app, the Application class exposes an "Install" method which executes when we select to install the OOB app.

In this method, you can try installing (using elevated priviliges) of your custom made ActiveX control (windows application) say MySilverlightHost. This app is nothing but a Windows Form having a silverlight host in it.

Yes! You heard me right. This guy (http://firstfloorsoftware.com/blog/hosting-silverlight-outside-the-browser/) has implemented a custom Windows form based silverlight host.

Now when your OOB is installed, the XAP file which is deployed to your system would be the source for the ActiveX app and will host its content in its Silverlight Host Control. And because it is a windows app, it can be configured to stay in the system tray.

Let me know if this guides you in correct direction.

WPF-it
  • 19,625
  • 8
  • 55
  • 71
  • 1
    What language/platform would you recommend the ActiveX app be built with? C++ on Native Runtime? C# on .NET? VB6 perhaps? BTW there are a many windows specific features that Silverlight "fails" to support and there as many devs annoyed that Silverlight doesn't support such-and-such simple "obvious requirement". They'd all be a lot happier if Microsoft had deliverd an API that supports all of these features. Oh, wait, they have its called .NET WPF. – AnthonyWJones Jul 31 '11 at 13:19
  • 1
    Yes Anthony I know WPF will do all this for us... but as per the question this is specific to OOB and because there is no support for installing OOB as a standard windows application is what makes it lack all such features. Imagine if there was such facility then OOB would have been a bigger hit than it is right now! And again, I have said this is just a guide or idea. I have not worked on this and do not know if the tips I gave this will work. I already said that in the beginning of the reply. I am not trying to create a debate here. – WPF-it Jul 31 '11 at 13:24
  • 1
    Since Silverlight 5 extends features of the ‘Trusted Application’ model (call existing unmanaged code directly from within Silverlight with PInvoke) it should be possible now to minimize OOB apps to tray, see: microsoft.com/silverlight/future/#trusted Can someone confirm this? – Mike Sep 13 '11 at 16:36
1

This is not possible. There is no API available to Silverlight to support this.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
0

Yes it is possible through Microsoft Native Extensions for Silverlight (NESL). ref: http://archive.msdn.microsoft.com/nesl

Taken from this url: The current version of NESL provides access to Windows 7 features like Sensors, Portable Devices, Speech, Taskbar and more.

Mathieu DSTP
  • 117
  • 3
  • 4
  • On SO, when providing a link to an external site, it is often best to give at least a high level summary of what the contents are in case the external link changes or is deleted. Future SO visitors will still have *something* to work with. – Fluffeh Sep 28 '12 at 11:00
0
Private Sub FullScr(sender As Object, e As MouseEventArgs)
    Application.Current.Host.Content.IsFullScreen = True
End Sub

Private Sub Nrml(sender As Object, e As MouseEventArgs)
    Application.Current.Host.Content.IsFullScreen = False
End Sub

Private Sub Min(sender As Object, e As MouseEventArgs)
    Application.Current.MainWindow.WindowState = WindowState.Minimized
End Sub
Zeni
  • 1
  • 2