<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # 三種方式設置特定設備UWP XAML view 開發者可以設置UWP特定設備xaml view,在桌面,手機,Iot,這個對于設置對不同設備的不同屏幕有用。我們可以使用RelativePanel,VisualStateTriggers,但是這樣我們的xaml很大,我們在弄的時候覺得想修改一個東西會讓我們把全部刪了。 為了讓我們可以在不同設備使用不同xaml view,我們可以有下面的方式: <!--more--> <div id="toc"></div> 在不同設備顯示不同背景顏色,文本,在同xaml,開始的頁面 <Page x:Class="DeviceFamily.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:DeviceFamily" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="Blue"> <TextBlock Foreground="White" Text="This is desktop." FontSize="72" VerticalAlignment="Center" HorizontalAlignment="Center" /> </Grid> </Page> ## 新建文件夾DeviceFamily-Type 里面的type是我們的設備,手機:Mobile,桌面:Desktop,IOT 在我們的解決方案新建一個文件夾,我們這里在手機Mobile ![](http://7xqpl8.com1.z0.glb.clouddn.com/16-4-6/21773005.jpg) 我們在新建DeviceFamily-Mobile新建xaml,MainPage ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438517274/deviceFamilyVS2_g6gazd.jpg) 新建類MainPage ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438517385/deviceFamilyVS3_zrnft1.jpg) 如果在手機運行,就會使用DeviceFamily-Mobile/MainPage.xaml,如果是其他,就會使用解決方案DeviceFamily/MainPage.xaml ## 在xaml文件加.DeviceFamily-Type 第二種方式在xaml文件加.DeviceFamily-Type,我們創建一個新的xaml,MainPage.DeviceFamily-Mobile.xaml ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438517871/deviceFamilyVS4_syhdit.jpg) 我們不能使用方法1和2在一個工程。 我們打開mobil會使用MainPage.DeviceFamily-Mobile.xaml ## InitializeComponent重載 添加一個DeviceFamily-Type文件夾在里面寫一個xaml會在MainPage.g.i.cs對InitializeComponent重載。 ```csharp public void InitializeComponent(global::System.Uri resourceLocator) { if (_contentLoaded) return; _contentLoaded = true; if (resourceLocator == null) { resourceLocator = new global::System.Uri("ms-appx:///MainPage.xaml"); } global::Windows.UI.Xaml.Application.LoadComponent(this, resourceLocator, global::Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); } ``` 可以指定一個uri到需要xaml ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438520919/deviceFamilyVS5_gdgxb8.jpg) ```csharp 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(); } } ``` 使用DeviceFamily指定視圖的效果,首先是桌面的MainPage.xaml ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438521366/desktop_yaxua2.jpg) 我們使用不同顏色放在mobil ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438521806/mobile1_sin4zt.jpg) 如果使用方式3,我們需要手動在main寫我們需要加載,我們有兩個xaml ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438522070/mobile-primary_j8v5fl.jpg) ![這里寫圖片描述](http://res.cloudinary.com/dvi6ot1t1/image/upload/v1438522070/mobile-secondary_gjihv4.jpg) 單頁面觸發器 我們可以在一個頁面不同設備使用不同的xaml [WindowsStateTriggers DeviceFamily sample](https://github.com/dotMorten/WindowsStateTriggers/blob/master/src/TestApp/Samples/DeviceFamilySample.xaml) https://github.com/igrali/UWP-DeviceFamily http://www.cnblogs.com/mushroom/p/5080032.html http://igrali.com/2015/08/02/three-ways-to-set-specific-devicefamily-xaml-views-in-uwp/
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看