zoukankan      html  css  js  c++  java
  • uwp使用资源限定符Devicefamily不同设备使用不同布局

    步骤:

    1. 删除MainPage.xaml
    2. App下新建两个文件夹:devicefamily-desktop,devicefamily-mobile
    3. App下新建MyPage.cs类
    4. 两个文件夹内新建MyPage.xaml文件,注意指向的类和命名空间为MyPage.cs类和它的命名空间
    5. 生成项目
    6. 初始化组件

    初始化组件:MyPage.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.UI.Xaml.Controls;
    
    namespace App1
    {
        public partial class MyPage : Page
        {
            public MyPage()
            {
                this.InitializeComponent(); // app生成后自动产生
            }
        }
    }

    两个文件下的MyPage.xaml

    devicefamily-desktop:
    <Page
        x:Class="App1.MyPage"
        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"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Grid>
            <TextBlock Text="桌面" FontSize="60" HorizontalAlignment="Center"/>
        </Grid>
    </Page>
  • 相关阅读:
    第一次Java作业
    第十一次作业
    第十次作业
    第九次作业
    第八次作业
    第七次作业
    第六次作业
    Java中数组自定义排序与优先级队列笔记
    力扣每日一题:删除链表的倒数第N个节点
    又一次离谱的错误——运算符优先级
  • 原文地址:https://www.cnblogs.com/maoriaty/p/9065347.html
Copyright © 2011-2022 走看看