Visual Studio 2015 Project Templates for Universal Windows Platform
List
- UWPSimpleTemplate - bare bones MVVM support
- UWPShellTemplate - provides a Hamburger navigation type AppShell with 4 different types of sample Views
- PrismSimpleTemplate - bare bones using Prism 6 for UWP
- PrismShellTemplate - same as UWPShellTemplate but using Prism 6 for UWP
UWPShellTemplate Notes
Acknowledgement - Most of the code for UWPShellTemplate came from these 2 sources:
- Channel 9 Build 2015 - Mical Lewis - Universal Navigation and Commanding for Your XAML - https://channel9.msdn.com/Events/Build/2015/2-97
- Universal Windows Sample - https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlNavigation which is the code from the Channel 9 video.
Features:
- AppShell with SplitView/Frame navigation pattern
- Custom NavMenuListView for SplitView.Pane
- Highlights select item in NavMenuListView
- Keyboard support is very good
- Supports Hierarchical navigation with a DrillinPage and a BasicSubPage
- CommandBar Page uses CommandBar and Menu flyouts in CommandBar.SecondaryCommands
- AdaptiveTrigger changes SplitView DisplayMode at "0" and "720" widths
My Changes:
- AppShell.xaml
- Replaced HamburgerButton ToogleButton with a Button because ToogleButton wouldn't respond to the Enter key.
- Added HamburgerButton_Click in code behind to toggle SplitView pane.
- Moved BackButton from controls:NavMenuListView to the right side of HamburgerButton.
- Added horizontal StackPanel to contain HamburgerButton, BackButton, Page Title, AutoSuggestBox.
- Changed BackButton IsEnabled attribute to a Visibility attribute.
- Added a BooleanToVisibilityConverter to BackButton's Visibility attribute
- Styles.xaml
- Commented out TextBlock in NavigationBackButtonStyle to make BackButton content just the back arrow
- Changes are commented in the code.
Sample Views:
- LandingPage - place for app features and instructions
- BasicPage - ordinary page
- DrillInPage - example of Hierarchical navigation
- BasicSubPage - subPage of DrillInPage's hierarchy
- CommandBarPage - example of commands and button flyouts
Feel free to delete any of the example pages and substitute your own.
Remember to:
- Give each page a name so that it's shown in the PageTitle
- Update AppShell.xaml.cs with NavMenuItems (including item icon and label) corresponding to your pages.
- Update AppShell.xaml with SplitView 'OpenPanelLength' to show complete NavMenuItem label
UWPSimpleTemplate Notes
Bare bones. No SplitView but some converters. Saves creating basic folders for a MVVM type project. Implements simple MVVM with Commanding.
PrismShellTemplate Notes
For some unknown reason even though the PrismShellTemplate builds successfully, there are some code squiggles and the Prism.Unity reference is missing. If that is the case, close Visual Studio then restart it and rebuild the solution.
Steps to make any of solutions a Visual Studio Project Template
- Open solution in Visual Studio
- Go to Main Menu->File menu
- Select Export Template
- Choose Template Type (select Project Template)
- Select Template Options (enter a Description)
- Press Finish button
- Project Template appears in Visual Studio under Installed -> Templates -> Visual C# Visual Studio creates a .zip file in:
- ..\Users(user)\Documents\Visual Studio 2015\Templates\ProjectTemplates
- ..\Users(user)\Documents\Visual Studio 2015\MyExportedTemplates
- ..\Users(user)\AppData\Roaming\Microsoft\VisualStudio\14.0\ProjectTemplatesCache (after it has been used)
- To remove the Project Template just delete the .zip files from the above 3 locations.
FixUps:
When the Visual C# Project Template is used to create a New Project all the namespaces are converted to the New Project name but the Packages.appxmanifest still contains template names so replace the word UWPShellTemplate with in these places:
- Application tab
- Display name
- Entry point - keep the .App
- Description
- Packaging tab
- Package display name
- Delete the Package name GUID and replace with a new one from Tools->Create GUID->#4 Registry removing the brackets
- If not using ARM device, switch Solution Platform to x86 or x64
Future Project Templates based on Navigation Patterns:
- Master-Detail
- Tabs
- Hub
- Pivots