Reputation: 6091
When a Windows Phone device is rotated to landscape, the page orientation tells me using an event with an enumeration. However, I'm trying to detect the landscape orientation without actually allowing the page to change orientation.
So, with Portrait being the only supported orientation on a page, how can I detect this same movement using the sensors? What values should I be looking for?
Upvotes: 1
Views: 434
Reputation: 89285
Calculate angle using accelerometer maybe, then you can decide whether phone is in Landscape or Potrait mode from angle value. Following snippet is not tested and I haven't played with accelerometer so far, just to give an idea to start :
private Accelerometer _accel = new Accelerometer();
public MainPage()
{
InitializeComponent();
_accel.ReadingChanged += (s, e) => Dispatcher.BeginInvoke(() =>
{
var angle = Math.Atan2(-x,y) * 180.0 / Math.PI;
.....
});
_accel.Start();
}
References :
Upvotes: 2