没有人知道如何使用设备当前连接的Wi-Fi网络的名称吗?
var orientation = DeviceDisplay.MainDisplayInfo.Orientation;
if (orientation == Orientation.Landscape)
{
MainPage = new Page1();
} else {
MainPage = new Page2();
}
解决我的问题的方法,到目前为止,我已经这样解决了:
在App.cs中:
公共应用(){
MainPage =new NavigationPage( new HomePage());
}
在HomePage.xaml.cs中:
受保护的覆盖无效OnSizeAllocated(双倍宽度,双倍高度){
base.OnSizeAllocated(width, height);
if(width > height)
{
_ = GoToPageAsync();
}
}
private async Task GoToPageAsync()
{
await Navigation.PushAsync(new TestPage());
}
在TestPage.xaml.cs中:
受保护的覆盖无效OnSizeAllocated(双倍宽度,双倍高度){
base.OnSizeAllocated(width, height);
if (width < height)
{
_ = GoToPageAsync();
}
}
private async Task GoToPageAsync()
{
await Navigation.PopAsync();
}
如果有人有更好的主意...