开源项目 AbsoluteBeginnersWin10 使用文档

开源项目 AbsoluteBeginnersWin10 使用文档

AbsoluteBeginnersWin10Video content can be found at https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners项目地址:https://gitcode.com/gh_mirrors/ab/AbsoluteBeginnersWin10

1. 项目的目录结构及介绍

AbsoluteBeginnersWin10/
├── Assets/
│   ├── Images/
│   └── Styles/
├── Pages/
│   ├── HomePage.xaml
│   ├── SettingsPage.xaml
│   └── AboutPage.xaml
├── Services/
│   ├── DataService.cs
│   └── NavigationService.cs
├── App.xaml
├── App.xaml.cs
├── MainPage.xaml
├── MainPage.xaml.cs
├── Package.appxmanifest
└── README.md

目录结构说明

  • Assets/: 存放项目中的静态资源,如图片和样式文件。
  • Pages/: 包含项目的各个页面文件,如主页、设置页和关于页。
  • Services/: 存放项目中的服务类,如数据服务和导航服务。
  • App.xaml: 应用程序的资源定义文件。
  • App.xaml.cs: 应用程序的代码隐藏文件。
  • MainPage.xaml: 主页面的定义文件。
  • MainPage.xaml.cs: 主页面的代码隐藏文件。
  • Package.appxmanifest: 应用程序的清单文件,包含应用的元数据和配置信息。
  • README.md: 项目的说明文档。

2. 项目的启动文件介绍

App.xaml

<Application
    x:Class="AbsoluteBeginnersWin10.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AbsoluteBeginnersWin10">
    <Application.Resources>
        <!-- 全局资源定义 -->
    </Application.Resources>
</Application>

App.xaml.cs

namespace AbsoluteBeginnersWin10
{
    sealed partial class App : Application
    {
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }

        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // 从之前的会话中恢复状态
                }

                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                Window.Current.Activate();
            }
        }

        void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
        }

        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            // 保存应用程序状态并停止任何后台活动
            deferral.Complete();
        }
    }
}

MainPage.xaml

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

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <!-- 页面内容 -->
    </Grid>
</Page>

MainPage.xaml.cs

namespace AbsoluteBeginnersWin10
{
    public sealed partial class Main

AbsoluteBeginnersWin10Video content can be found at https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners项目地址:https://gitcode.com/gh_mirrors/ab/AbsoluteBeginnersWin10

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阮曦薇Joe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值