Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparing orientations? #17

Open
memmons-ntst opened this issue Oct 18, 2018 · 4 comments
Open

Comparing orientations? #17

memmons-ntst opened this issue Oct 18, 2018 · 4 comments

Comments

@memmons-ntst
Copy link

memmons-ntst commented Oct 18, 2018

What is the correct way to do orientation comparisons? I've tried the following, none of which work:

bool fail1 = CrossDeviceOrientation.Current == 2;
bool fail2 = CrossDeviceOrientation.Current == DeviceOrientations.Portrait;
bool fail3 = CrossDeviceOrientation.Current.Equals(DeviceOrientations.Portrait);

Coming from Swift/Obj-C, I'm sure there is some dumb thing I am doing here. Also, would be great if you included an example like this in the docs.

@wcoder
Copy link
Owner

wcoder commented Oct 19, 2018

Hi @memmons-ntst

Current property has platform implementation of the plugin with interface IDeviceOrientation as a singleton, next step you will need to get CurrentOrientation value and compare with DeviceOrientations enum value:

CrossDeviceOrientation.Current.CurrentOrientation == DeviceOrientations.Portrait

@MagicAndre1981
Copy link

@wcoder can I also do this check in pure XAML? I want to set Margin/Padding based on Idiom and Orientation status. Currently I do this in code at OnSizeAllocated but here I can't use XAML Reloader tools to see the output if I change values, here I have to compile the app again and run it again.

@wcoder
Copy link
Owner

wcoder commented May 10, 2019

@MagicAndre1981 plugin doesn't provide any solutions out of the box for support from XAML.

I think you can implement your case via Xamarin.Forms Triggers.

@MagicAndre1981
Copy link

any hint how to do this via Triggers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants