Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect the OS from a silverlight application?

I have a Silverlight3 application that is meant to run on both Windows and Mac OS environments. I would like to know in runtime if my application is running on a Windows or Mac so I can tweak a few things to the way users are accustomed to in their operating system of choice.

For example, in Windows it is the norm to use "OK" "Cancel" buttons, while in Mac OS the norm is "Cancel" "OK" buttons (reverse order).

Any ideas?

like image 515
sprite Avatar asked Sep 10 '09 06:09

sprite


1 Answers

There are two ways.

From Silverlight:

string os = Environment.OSVersion.Platform.ToString();
string version = Environment.OSVersion.Version.ToString();

From ASP.NET and send it to Silverlight:

StringBuilder sb = new StringBuilder();
sb.AppendFormat("UserAgent={0}", Request.UserAgent);
Xaml1.InitParameters = sb.ToString();
like image 123
NewAgeSolution Avatar answered Sep 28 '22 04:09

NewAgeSolution