public HomePageViewModel() { GetDeviceOrientationCommand = new Command(async() => { IDeviceOrientationService service = DependencyService.Get <IDeviceOrientationService>(); DeviceOrientation orientation = service.GetOrientation(); if (orientation.IsLandscape()) { await App.Current.MainPage.DisplayAlert("Orientation", "The device orientation is Landscape", "Ok"); } else { await App.Current.MainPage.DisplayAlert("Orientation", "The device orientation is Portrait", "Ok"); } }); }
public virtual bool ShouldShowToolbarButton() { if (Device.Idiom == TargetIdiom.Phone) { return(true); } FlyoutLayoutBehavior behavior = FlyoutLayoutBehavior; DeviceOrientation orientation = Device.Info.CurrentOrientation; bool isSplitOnLandscape = (behavior == FlyoutLayoutBehavior.SplitOnLandscape || behavior == FlyoutLayoutBehavior.Default) && orientation.IsLandscape(); bool isSplitOnPortrait = behavior == FlyoutLayoutBehavior.SplitOnPortrait && orientation.IsPortrait(); return(behavior != FlyoutLayoutBehavior.Split && !isSplitOnLandscape && !isSplitOnPortrait); }