1、DeviceFamily-Type文件夾 將Index.xaml拷貝到DeviceFamily-Desktop 和DeviceFamily-Mobile,刪除這2個目錄下的Index.xmal.cs 文件。 2、DeviceFamily-Type擴展 通過創建新的XAML視圖達到同樣的效果,使用 ...
1、DeviceFamily-Type文件夾
將Index.xaml拷貝到DeviceFamily-Desktop 和DeviceFamily-Mobile,刪除這2個目錄下的Index.xmal.cs 文件。
2、DeviceFamily-Type擴展
通過創建新的XAML視圖達到同樣的效果,使用同樣的名稱,但是DeviceFamily-Type是擴展的。比如MainPage頁面,它意思是添加一個新的XAML視圖文件叫MainPage.DeviceFamily-Mobile.xaml,它放在和MainPage同樣的文件夾。
3、InitializeComponent重載
public MainPage() { if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { if (usePrimary) { InitializeComponent(new Uri("ms-appx:///PrimaryMainPage.xaml", UriKind.Absolute)); } else { InitializeComponent(new Uri("ms-appx:///SecondaryMainPage.xaml", UriKind.Absolute)); } } else { InitializeComponent(); } }
4、VisualStateManager
<VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="VisualStateGroup"> <VisualState x:Name="Narrow"> <VisualState.StateTriggers> <AdaptiveTrigger MinWindowWidth="0" /> </VisualState.StateTriggers> <VisualState.Setters> <Setter Target="tabLayout.(Grid.Column)" Value="1" /> <Setter Target="tabLayout.(Grid.Row)" Value="1" /> <Setter Target="pivot.(Grid.Column)" Value="1" /> <Setter Target="pivot.(Grid.Row)" Value="0" /> <Setter Target="tabLayout.Orientation" Value="Horizontal" /> <Setter Target="tabLayout.Width" Value="Auto" /> </VisualState.Setters> </VisualState> <VisualState x:Name="Wide"> <VisualState.StateTriggers> <AdaptiveTrigger MinWindowWidth="501" /> </VisualState.StateTriggers> <VisualState.Setters> <Setter Target="tabLayout.(Grid.Column)" Value="0" /> <Setter Target="tabLayout.(Grid.Row)" Value="0" /> <Setter Target="pivot.(Grid.Column)" Value="1" /> <Setter Target="pivot.(Grid.Row)" Value="0" /> <Setter Target="tabLayout.Orientation" Value="Vertical" /> <Setter Target="tabLayout.Width" Value="60" /> </VisualState.Setters> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups>
原文出處
http://www.cnblogs.com/kiminozo/p/4738355.html
http://www.cnblogs.com/mushroom/p/5080032.html
轉載請標明出處:http://www.cnblogs.com/xiaocaidev/p/7045500.html,本文出自:【xiaocaidev的博客】