-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: default project improvements #10388
Comments
Don't wait for these changes. Many simple changes have been waiting to be implemented for years. |
I love these suggestions. I know @niels9001 has some strong feelings about the default templates too. |
I feel like you have many valid points here, but I don't think all of these should be added to the blank template. While I could see the existing template gets cleaned up a little, I don't want a bunch of opinioned stuff in a blank template. IMHO the blank template already has too much stuff in it with silly button-click stuff that you always have to remove. |
@dotMorten Any thoughts on what you'd consider opinioned for a Blank Template? Using the new TitleBar would add additional XAML, but from a UX perspective it would still launch an empty, modern looking window (IMO this experience should be the default experience when developing a new WinUI app - also since WPF with Fluent Theming provides that experience as well). Sure, the XAML wouldn't be 'blank' - but the end result would be. |
The titlebar is the prime example of things which should not be in the default template. It's broken since ages ago. Imho remove the unused stuff and for anything else create a new template or integrate into Template Studio. |
You could have an Empty/Blank project template, with nothing added. And then have a Modern App project template, with the Titlebar all wired up, and the default assets required such as an ico file. |
Proposal: default project improvements
Summary
The current project template for a WinUI3 app is lacking a lot of issues. I recently created a new project which I wanted to use for a demo. It is strange that I had to add so many things before I could use it. These should be out of the box.
In this proposal I will show all the things I think are missing or wrong in the current template.
Scope
Tiles
subfolder folder of theAssets
folderVisual Assets
Place the Visual Assets in a
Tiles
subfolder folder of theAssets
folderCurrently all tiles are placed in the
Assets
folder itself. I often create extra folders too likeFonts
,Sounds
,Images
but they don't have to be there in the template.The
Package.appxmanifest
should point to this folder.Remove unused tiles
The
Wide310x150Logo.png
andSplashScreen.png
can be removed from the project. They are not used in WinUI.Add an Icon.ico and set it on the Window
A WinUI3 should have an Icon file otherwise the app will get a blue background color in the TaskBar. It took me hours to find a solution for it. Thanks to many on the Discord group.
In the
Assets/Tiles
folder I would like to have anIcon.ico
file with theBuild Action
set toContent
. In the 'App.xaml.cs' file you need to callSetIcon()
.For this demo I converted a Smiley.png into an Icon file using the `Simple Icon File Maker' app from Joe Finney.
MainWindow
Add MicaBackdrop
The ugly white background is now gone. And you have Mica.
Add the new TitleBar
If you are using WinAppSDK version 1.7 (currently in preview) you could use the new TitleBar control in your Window
The Title of the TitleBar is databound to the Title property of the window. The IconSource is set to the StoreLogo.png.
You also have to set the ExtendsContentIntoTitleBar and the Title, so I changed the constructor of the MainWindow into this. Using the
Package.DisplayName
is better than using some hard coded string.Add a Minimum size
Add a solution to the MainWindow to set the minimum size. Nobody wants this.
Replace the 'Click Me' Button for a Frame and navigate to a MainPage
I think the currently used 'Click Me' button is quite useless. I think you should not have any XAML controls in a Window. Windows are limited. They cannot have Resources. In UWP apps we are used to write XAML in Pages, by default a
MainPage.xaml
. That is what we should do in WinUI too. We can also use the BackButton logic of the TitleBar to make that easier too.In the constructor of the
MainWindow
you can navigate to aMainPage
and also have theBackRequested
handler.This results in a
Back
button in theTitleBar
if back navigation is possible.Introduce a MainPage with a Counter
We need a MainPage and it needs something more than only a
Click Me
button. In Blazor and Maui there is a Counter page. Maybe we should implement that too.Folders
Add a GlobalUsings.cs
We don't have ImplicitUsings for WinUI apps like ASP.NET, WPF or Windows Forms. Let's create a GlobalUsings.cs file to mimic this behavior.
Introduce a Views folder
All view related items (Windows, Pages, Resources, Controls, Dialogs) should be placed in a Views folder. Preferably with subfolders for each type.
Default Styles.xaml Resource Dictionary
The project could have a
Styles.xaml
resource dictionary which is merged from theApp.xaml
file. Having a separate file for it learns unexperienced developers to use styling and the use of Resource Dictionaries.Default Themes.xaml Resource Dictionary
Add a Themes.xaml resource dictionary and reference it from the App.xaml. If new developers know that this exists, they will start using it (hopefully).
Important Notes
I'm quite sure that there are many other improvements to be made. Is my priority ok? Please react on this proposal to get them all discussed.
The text was updated successfully, but these errors were encountered: