How to get the device orientation changed event under Windows Phone

后端 未结 1 1785
清酒与你
清酒与你 2021-01-16 08:37

With windows phone, is there an event I can register for when the device entered landscape mode?

The reason why I am asking this is because we have a view with an i

相关标签:
1条回答
  • 2021-01-16 09:18

    Your best bet would be describing to Windows.Current.SizeChanged event and testing if width is more than height. There is also a sensor for this, but is is a bit problematic, take a look at http://www.jayway.com/2014/10/06/detecting-orientation-in-universal-apps-windows-phone-8-1/.

    .xaml

    <ContentDialog
        x:Class="App1.ContentDialog1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App1"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        SizeChanged="SizeChangedEvent">
    
        <--! Other Code -->
    
    </ContentDialog>
    

    .cs

    private void SizeChangedEvent(object sender, SizeChangedEventArgs e)
    {
    }
    
    0 讨论(0)
提交回复
热议问题