UWP Windows歷史上最漂亮的UWP框架出爐!!!


UWP Windows歷史上最漂亮的UWP框架出爐!!!

 

本框架基於微軟的開源項目WTS開發,並在其基礎上增加了FDS(流暢設計元素,高光、亞克力等)、多語言系統、沉浸式體驗(擴展內容到標題欄)

同時又保留了WTS的強大擴展性,你可以添加你所需要的頁面,來快速定制自己個性化的App。

 

先看圖,有圖有真相!(點開圖看原圖更清晰)

 

Light Mode:

 

Dark mode:

 

 

簡介:

0、App.xaml(.cs)

  啟動App的引導,包含了類似C語言的Main()函數一樣

1、ShellPage.xaml(.cs)

  App的運行殼,修改其xaml可同意定制App的外觀,同時包含了左側導航菜單,右側的Content。

  這二者都運用了Fluent Design System元素,所以App才顯得這么漂亮😜

2、MainPage.xaml(.cs)

  主界面,即打開App要呈現給用戶的界面

3、FirstRunDialog.xaml(.cs)

  第一次運行時展現給用戶的信息,比如介紹一下你的App。可以通過修改資源文件中的FirstRun_Body.Text來實現

4、WhatsNewDialog.xaml(.cs)

  后續每次更新提供的更新日志等,可以通過修改資源文件中的AfterUpdate_Body.Text來實現

5、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 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM