DeviceFamily Veiws 可以为特定的设备(Mobile、Desktop等)制作特定的XAML视图,这种方式可以完全定制XMAL和共享后台代码。

  以 Mobile 和 Desktop 为例:

  • 新建两个文件夹 DeviceFamily-Miobile 和 DeviceFamily-Desktop ;

  • 然后在两个文件夹中都添加一个 MainPage.xaml ;

         

  • 如果在 Mobile 设备上运行应用程序,它将从DeviceFamily-Mobile/MainPage.xaml 加载 XMAL; 如果在 Desktop 设备上运行应用程序,它将从DeviceFamily-Desktop/MainPage.xaml 加载 XMAL; 对于其他设备将加载主文件夹下的 MainPage.xaml;
  • Example
  • DeviceFamily-Mobile/MainPage.xaml
 Page
     x:Class="_DeviceFamily.DeviceFamily_Mobile.MainPage"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="using:_DeviceFamily.DeviceFamily_Mobile"
     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 Text="Hello DeviceFamily-Mobile" VerticalAlignment="Center" FontSize="24" />
     </Grid>
 </Page>
  • Mobile 上的运行效果

  • DeviceFamily-Desktop/MainPage.xaml
 <Page
     x:Class="_DeviceFamily.DeviceFamily_Desktop.MainPage"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="using:_DeviceFamily.DeviceFamily_Desktop"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     mc:Ignorable="d">

     <Grid Background="Red">
         <TextBlock VerticalAlignment="Center" Text="Hello DeviceFamily-Desktop" FontSize="56" />
     </Grid>
 </Page>
  • Desktop 上的运行效果

  • 主文件下的 MainPage.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="Yellow">
        <TextBlock VerticalAlignment="Center" Text="Hello DeviceFamily-Desktop" FontSize="48" />
    </Grid>
</Page>
  • 运行效果(由于没有 Table  之类的第三种设备,所以此运行效果省略 gg)

DeviceFamily XAML Views(一)的更多相关文章

  1. Three ways to set specific DeviceFamily XAML Views in UWP

    Three ways to set specific DeviceFamily XAML Views in UWP http://igrali.com/2015/08/02/three-ways-to ...

  2. Windows10-UWP中设备序列显示不同XAML的三种方式[3]

    阅读目录: 概述 DeviceFamily-Type文件夹 DeviceFamily-Type扩展 InitializeComponent重载 结论 概述 Windows10-UWP(Universa ...

  3. Xamarin.Android和UWP之MVVM的简单使用(二)

    0x01 前言 前面一篇,Xamarin.Android和UWP之MVVM的简单使用(一),主要讲了MvvmLight的简单使用 这篇主要讲讲MvvmCross的简单使用,例子的话,还是和上篇的一样. ...

  4. WPF中如何调整TabControl的大小,使其跟随Window的大小而改变?

    多年不写技术博客,手生的很,也不知道大家都关注什么,最近在研究Wpf及3d模型的展示,碰到很多问题,这个是最后一个问题,写出来小结一下...... WPF中如何调整TabControl的大小,使其跟随 ...

  5. 用户控件UserControl图片资源定位(一)---Xaml引用图片

    MEF编程实现巧妙灵活松耦合组件化编程,一些细节需要花费不小心思去处理: 其中组件中若包含用户控件,且需要访问图片资源,那么Xaml引用资源需要做以下设置 1. 用户控件(usercontrol)所在 ...

  6. UAP如何根据DeviceFamily显示不同的页面

    背景 微软推出UAP 推荐使用响应式的UI,但是难免遇到一些特殊情况需要使用不同的Page来在不同的设备显示. 微软目前最新的VS2015在10074上安装后能够支持这个功能特性,只是暂时没有文档介绍 ...

  7. silverlight visifire控件图表制作——silverlight 静态页面xaml

    一.silverlight 静态页面 1. 时间控件:DatePicker ,添加引用: xmlns:sdk="clr-namespace:System.Windows.Controls;a ...

  8. 三种方式设置特定设备UWP XAML view

    开发者可以设置UWP特定设备xaml view,在桌面,手机,Iot,这个对于设置对不同设备的不同屏幕有用.我们可以使用RelativePanel,VisualStateTriggers,但是这样我们 ...

  9. Introducing XAML Standard and .NET Standard 2.0

    XAML Standard We are pleased to announce XAML Standard, which is a standards-based effort to unify X ...

随机推荐

  1. Linux IPC tcp/ip socket 编程

    模型 #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include < ...

  2. linux下怎么查看ssh的用户登录日志

    linux下登录日志在下面的目录里: cd /var/log 查看ssh用户的登录日志: less secure linux日志管理: 1. 日志简介 日志对于安全来说,非常重要,他记录了系统每天发生 ...

  3. [嵌入式开发入门]4412开发板从零建立Linux最小系统

    本文转自iTOP-4412开发板实战教程书籍 http://www.topeetboard.com iTOP-4412开发板不仅可以运行Android,还可以运行简单的Linux最小文件系统. 最小L ...

  4. PADS Logic Decal、Layout Decal绘制

    绘制Logic Decal图形: 1.Gate Decal与Part Type的区别: Gate Decal:即元器件在原理图中所展现出来的形状 Part Type:将元件图形.电气特性都进行定义后所 ...

  5. NYOJ-取石子

    (一) 描述一天,TT在寝室闲着无聊,和同寝的人玩起了取石子游戏,而由于条件有限,他/她们是用旺仔小馒头当作石子.游戏的规则是这样的.设有一堆石子,数量为N(1<=N<=1000000), ...

  6. 第64课 C++中的异常处理(上)

    1. C++内置的异常处理:try-catch (1)try语句处理正常代码逻辑 (2)catch语句处理异常情况 (3)try语句中的异常由对应的catch语句处理,如果对应的catch中没有处理该 ...

  7. CSS垂直居中精华总结

    1  table-cell方式 将center元素的包含框display设置为table,center元素的display设置为table-cell,vertical-align设置为middle. ...

  8. Oracle round函数是什么意思?怎么运用?

    如何使用 Oracle Round 函数 (四舍五入) 描述 : 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果. SELECT ROUND( number, [ decimal_p ...

  9. AngularJs 1.5 $location获取url参数

    地址:http://localhost/waservice.html?id=17 获取参数id的值 app.config(['$locationProvider', function ($locati ...

  10. CoreAnimation笔记

    核心动画继承结构 CoreAnimation Core Animation是直接作用在CALayer上的(并非UIView上)非常强大的跨Mac OS X和iOS平台的动画处理API,Core Ani ...