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 

相關文章
相關標籤/搜索