UWP Windows历史上最漂亮的UWP框架出炉!!!

UWP Windows历史上最漂亮的UWP框架出炉!!!git

 

本框架基于微软的开源项目WTS开发,并在其基础上增长了FDS(流畅设计元素,高光、亚克力等)、多语言系统、沉浸式体验(扩展内容到标题栏)github

同时又保留了WTS的强大扩展性,你能够添加你所须要的页面,来快速定制本身个性化的App。windows

 

先看图,有图有真相!(点开图看原图更清晰)app

 

Light Mode:框架

 

Dark mode:ide

 

 

简介:函数

0、App.xaml(.cs)ui

  启动App的引导,包含了相似C语言的Main()函数同样spa

一、ShellPage.xaml(.cs)设计

  App的运行壳,修改其xaml可赞成定制App的外观,同时包含了左侧导航菜单,右侧的Content。

  这两者都运用了Fluent Design System元素,因此App才显得这么漂亮😜

二、MainPage.xaml(.cs)

  主界面,即打开App要呈现给用户的界面

三、FirstRunDialog.xaml(.cs)

  第一次运行时展示给用户的信息,好比介绍一下你的App。能够经过修改资源文件中的FirstRun_Body.Text来实现

四、WhatsNewDialog.xaml(.cs)

  后续每次更新提供的更新日志等,能够经过修改资源文件中的AfterUpdate_Body.Text来实现

五、SettingsPage.xaml(.cs)

  设置面板,我增长了多语言选项,你基于本框架,还能够添加更多的语言。可是不要忘记在strings文件夹添加对应的资源文件

 

固然,光上面介绍的页面不可以知足对用户层面的须要,那么你可使用WTS向导,添加须要的页面/功能。

 

在你添加了新的页面后,进入ShellPage.xaml.cs中,添加上对应的代码,实现菜单导航。

     private void PopulateNavItems()
        {
            _primaryItems.Clear();
            _secondaryItems.Clear();

            // TODO WTS: Change the symbols for each item as appropriate for your app
            // More on Segoe UI Symbol icons: https://docs.microsoft.com/windows/uwp/style/segoe-ui-symbol-font
            // Or to use an IconElement instead of a Symbol see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/projectTypes/navigationpane.md
            // Edit String/en-US/Resources.resw: Add a menu item title for each page
            _primaryItems.Add(ShellNavigationItem.FromType<MainPage>("Shell_Main".GetLocalized(), Symbol.Document));

            _secondaryItems.Add(ShellNavigationItem.FromType<SettingsPage>("Shell_Settings".GetLocalized(), Symbol.Setting));
        }

 

 

在拓展内容到标题栏的时候,须要区分一下桌面版和手机版代码略不一样

手机版不须要设置标题栏,因此须要把标题栏所在的那一行行高设置为0(必选),而且进入全屏模式(可选)。

       if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                // Hide default title bar.
                var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
                coreTitleBar.ExtendViewIntoTitleBar = true;
                UpdateTitleBarLayout(coreTitleBar);

                // Set XAML element as a draggable region.
                Window.Current.SetTitleBar(AppTitleBar);

                var view = ApplicationView.GetForCurrentView();
                view.TitleBar.ButtonBackgroundColor = Colors.Transparent;

                // Register a handler for when the size of the overlaid caption control changes.
                // For example, when the app moves to a screen with a different DPI.
                coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;

                // Register a handler for when the title bar visibility changes.
                // For example, when the title bar is invoked in full screen mode.
                coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged;
            }
            else
            {
                rowTitleBar.Height = new GridLength(0);
                var view = ApplicationView.GetForCurrentView();
                view.TryEnterFullScreenMode();
            }

 

 

还有一点必须注意的是,AppTitleBar背景色必须设置透明,不然标题栏不能移动双击等操做,切记!!!

<Grid x:Name="AppTitleBar" Background="Transparent">

 

 

关于设置里面的多语言,我选择了存储在本地

        private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string temp = comboBoxLanguage.SelectedItem.ToString();
            string[] tempArr = temp.Split(' ');
            ApplicationData.Current.LocalSettings.Values["strCurrentLanguage"] = tempArr[0];
        }

你也能够存储在RoamSettings里面来漫游设置,这样能够实现设置跨Win 10平台。

 

注意:本框架最低系统要求是创意者更新Build15063(Creators Update),目标系统是秋季创意者更新Build16299(Fall Creators Update)

 

项目开源地址:https://github.com/hupo376787/A-Beautiful-UWP-Frame.git

 

 

 

 👇

 👇

 👇

 👇

 👇

 👇

 👇

 👇

 :敢不敢把ShellPage.xaml中的最外层的Grid fcu:Background 画笔刷子换成 SystemControlBackgroundAccentRevealBorderBrush 

相关文章
相关标签/搜索