C# 仅在Windows 10(桌面)中显示文本框
我只想在Windows 10(桌面)中显示一个文本框,不想在Windows 10 Mobile中显示相同的文本框。有可能吗?我建议检查特定功能而不是检测操作系统。Base.Meta。ApIdIt是你的最佳选择。 但是如果你只在乎它是不是一部手机,那就去寻找只有手机才会有的东西。。。这是未经测试的,但您可以这样做:C# 仅在Windows 10(桌面)中显示文本框,c#,visual-studio-2015,uwp,uwp-xaml,C#,Visual Studio 2015,Uwp,Uwp Xaml,我只想在Windows 10(桌面)中显示一个文本框,不想在Windows 10 Mobile中显示相同的文本框。有可能吗?我建议检查特定功能而不是检测操作系统。Base.Meta。ApIdIt是你的最佳选择。 但是如果你只在乎它是不是一部手机,那就去寻找只有手机才会有的东西。。。这是未经测试的,但您可以这样做: bool isHardwareButtonsAPIPresent = Windows.Foundation.Metadata.ApiInformation.IsType
bool isHardwareButtonsAPIPresent =
Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");
if (isHardwareButtonsAPIPresent)
{
// The true
}
以下是我在项目中使用的一个小方法,用于检查我的应用程序是否在手机上或非手机上
public static bool IsMobile()
{
String str = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
bool _isMobile = (str == "Windows.Mobile") ? true : false;
return _isMobile;
}
更新: 如果要在代码隐藏中使用
textBox.Visibility = (IsMobile()) ? Visibility.Collapsed : Visibility.Visible;
如果要通过
数据绑定使用
,可以创建一个属性并使用相同的逻辑返回可见性
的可能副本还需要更多信息。但我如何将这一点与我希望文本框仅在Windows 10(桌面)中显示而不在Windows 10 Mobile中显示的事实联系起来?这种“连接”是我无法做到的。但我如何将其与我希望文本框仅在Windows 10(桌面)中显示而不在Windows 10 Mobile中显示的事实联系起来?这个“连接”是我不能做的。请将文本框的Visible属性设置为isHardwareButtonsAPIPresent的值。