views:

404

answers:

4

Hello all,

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?

A: 

Not familiar with Silverlight, but I bet you can get hold of User-Agent HTTP header, which includes OS name.

Anton Gogolev
A: 

Not exactly what I was looking for. I want a way to get this information from the Silverlight application itself on runtime. Since silverlight3 applications can be run offline, there must be a way to get this information in such a case.

sprite1g
+6  A: 

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 as

StringBuilder sb = new StringBuilder(); sb.AppendFormat("UserAgent={0}", Request.UserAgent); Xaml1.InitParameters = sb.ToString();

NewAgeSolution
A: 

Thanks NewAgeSolution, that was exactly what I was looking for (specifically the first option).

Unfortunately I can't Vote Up your answer yet as I don't even have 15 reputation.

Thanks again.

sprite1g