How to detect the OS from a silverlight application?

与世无争的帅哥 提交于 2020-02-01 03:08:53

问题


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?


回答1:


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();



回答2:


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



来源:https://stackoverflow.com/questions/1403727/how-to-detect-the-os-from-a-silverlight-application

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