如何从Silverlight应用程序检测操作系统? [英] How to detect the OS from a silverlight application?

查看:78
本文介绍了如何从Silverlight应用程序检测操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight3应用程序,可以在Windows和Mac OS环境中运行.我想在运行时知道我的应用程序是在Windows还是Mac上运行,因此我可以根据用户选择的操作系统来调整一些习惯.

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.

例如,在Windows中,通常使用"OK"(确定)取消"按钮,而在Mac OS中,使用"Cancel"确定"按钮(相反的顺序).

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).

有什么想法吗?

推荐答案

有两种方法.

从Silverlight:

From Silverlight:

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

从ASP.NET并将其发送到Silverlight:

From ASP.NET and send it to Silverlight:

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

这篇关于如何从Silverlight应用程序检测操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆