diff --git a/README.md b/README.md index 636000bbcf..0537175150 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ This code is distributed under the terms and conditions of the [MIT license](LIC ## Privacy Statement -The extension does [log basic telemetry](docs/telemetry.md) for what is being selected. Please read the [Microsoft privacy statement](http://go.microsoft.com/fwlink/?LinkId=521839) for more information. +The extension does [log basic telemetry](docs/telemetry.md) for what is being selected. Our [Telemetry Data](telemetryData.md) page has the trends from the telemetry. Please read the [Microsoft privacy statement](http://go.microsoft.com/fwlink/?LinkId=521839) for more information. ## .NET Foundation @@ -90,15 +90,17 @@ This project is supported by the [.NET Foundation](https://dotnetfoundation.org) - [Rapid Xaml Toolkit](https://github.com/Microsoft/Rapid-XAML-Toolkit) - [Windows Community Toolkit](https://github.com/Microsoft/WindowsCommunityToolkit) -## Libraries and frameworks we use in our generated projects - +## Frameworks and libraries in generated code not created by our team +**Frameworks** - [Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro) +- [MVVMLight](https://github.com/lbugnion/mvvmlight) +- [Prism](https://github.com/PrismLibrary/Prism) + +**Libraries** - [Microsoft AppCenter SDK](https://github.com/Microsoft/AppCenter-SDK-DotNet) - [Microsoft Store Services SDK](https://marketplace.visualstudio.com/items?itemName=AdMediator.MicrosoftStoreServicesSDK) -- [Microsoft Win 2D](https://github.com/Microsoft/Win2D) -- [MVVMLight](https://github.com/lbugnion/mvvmlight) +- [Microsoft Win2D](https://github.com/Microsoft/Win2D) - [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) -- [Prism](https://github.com/PrismLibrary/Prism) - [Telerik UI For UWP](https://github.com/telerik/UI-For-UWP) - [Windows Azure Messaging Managed](https://www.nuget.org/packages/WindowsAzure.Messaging.Managed) - [Windows Community Toolkit](https://github.com/Microsoft/WindowsCommunityToolkit) diff --git a/_build/assemblies.cs-cz.signconfig.xml b/_build/assemblies.cs-cz.signconfig.xml index cf5bd2aa78..57a09ff2ee 100644 --- a/_build/assemblies.cs-cz.signconfig.xml +++ b/_build/assemblies.cs-cz.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.de-de.signconfig.xml b/_build/assemblies.de-de.signconfig.xml index 84ea3afac7..02602698ab 100644 --- a/_build/assemblies.de-de.signconfig.xml +++ b/_build/assemblies.de-de.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.en-us.signconfig.xml b/_build/assemblies.en-us.signconfig.xml index 11277927bf..bdda0190a1 100644 --- a/_build/assemblies.en-us.signconfig.xml +++ b/_build/assemblies.en-us.signconfig.xml @@ -1,6 +1,6 @@ - + diff --git a/_build/assemblies.es-es.signconfig.xml b/_build/assemblies.es-es.signconfig.xml index 1e53eb7874..7cd0a7f75c 100644 --- a/_build/assemblies.es-es.signconfig.xml +++ b/_build/assemblies.es-es.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.fr-fr.signconfig.xml b/_build/assemblies.fr-fr.signconfig.xml index 5828b57c21..774d3fc0c0 100644 --- a/_build/assemblies.fr-fr.signconfig.xml +++ b/_build/assemblies.fr-fr.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.it-it.signconfig.xml b/_build/assemblies.it-it.signconfig.xml index 3b40d1524d..c8630744f7 100644 --- a/_build/assemblies.it-it.signconfig.xml +++ b/_build/assemblies.it-it.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.ja-jp.signconfig.xml b/_build/assemblies.ja-jp.signconfig.xml index e814421d04..a036403b1d 100644 --- a/_build/assemblies.ja-jp.signconfig.xml +++ b/_build/assemblies.ja-jp.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.ko-kr.signconfig.xml b/_build/assemblies.ko-kr.signconfig.xml index 89ec7df188..d052ec9ee0 100644 --- a/_build/assemblies.ko-kr.signconfig.xml +++ b/_build/assemblies.ko-kr.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.pl-pl.signconfig.xml b/_build/assemblies.pl-pl.signconfig.xml index 86510855d0..3420128bf1 100644 --- a/_build/assemblies.pl-pl.signconfig.xml +++ b/_build/assemblies.pl-pl.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.pt-br.signconfig.xml b/_build/assemblies.pt-br.signconfig.xml index efcf4259f8..0178cbd731 100644 --- a/_build/assemblies.pt-br.signconfig.xml +++ b/_build/assemblies.pt-br.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.ru-ru.signconfig.xml b/_build/assemblies.ru-ru.signconfig.xml index 0f0ea39a35..c09e9830fd 100644 --- a/_build/assemblies.ru-ru.signconfig.xml +++ b/_build/assemblies.ru-ru.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.signconfig.xml b/_build/assemblies.signconfig.xml index 26f8b03e84..cdfe847e67 100644 --- a/_build/assemblies.signconfig.xml +++ b/_build/assemblies.signconfig.xml @@ -1,11 +1,11 @@ - - - - - - + + + + + + diff --git a/_build/assemblies.tr-tr.signconfig.xml b/_build/assemblies.tr-tr.signconfig.xml index 7c74e98c14..d47b6af1f5 100644 --- a/_build/assemblies.tr-tr.signconfig.xml +++ b/_build/assemblies.tr-tr.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.zh-cn.signconfig.xml b/_build/assemblies.zh-cn.signconfig.xml index 883cb9fa51..6692940bd2 100644 --- a/_build/assemblies.zh-cn.signconfig.xml +++ b/_build/assemblies.zh-cn.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/_build/assemblies.zh-tw.signconfig.xml b/_build/assemblies.zh-tw.signconfig.xml index 8ef4481338..02ac35213a 100644 --- a/_build/assemblies.zh-tw.signconfig.xml +++ b/_build/assemblies.zh-tw.signconfig.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/code/src/UI/Generation/GenComposer.cs b/code/src/UI/Generation/GenComposer.cs index ff79c675c2..f7b0b26fbb 100644 --- a/code/src/UI/Generation/GenComposer.cs +++ b/code/src/UI/Generation/GenComposer.cs @@ -122,10 +122,10 @@ public static IEnumerable Compose(UserSelection userSelection) } AddProject(userSelection, genQueue); - AddTemplates(userSelection.Pages, genQueue, userSelection); - AddTemplates(userSelection.Features, genQueue, userSelection); + AddTemplates(userSelection.Pages, genQueue, userSelection, false); + AddTemplates(userSelection.Features, genQueue, userSelection, false); - genQueue = AddInCompositionTemplates(genQueue, userSelection); + genQueue = AddInCompositionTemplates(genQueue, userSelection, false); return genQueue; } @@ -157,10 +157,10 @@ public static IEnumerable ComposeNewItem(UserSelection userSelection) return genQueue; } - AddTemplates(userSelection.Pages, genQueue, userSelection); - AddTemplates(userSelection.Features, genQueue, userSelection); + AddTemplates(userSelection.Pages, genQueue, userSelection, true); + AddTemplates(userSelection.Features, genQueue, userSelection, true); - genQueue = AddInCompositionTemplates(genQueue, userSelection); + genQueue = AddInCompositionTemplates(genQueue, userSelection, true); return genQueue; } @@ -168,7 +168,7 @@ public static IEnumerable ComposeNewItem(UserSelection userSelection) private static void AddProject(UserSelection userSelection, List genQueue) { var projectTemplate = GetProjectTemplate(userSelection.ProjectType, userSelection.Framework, userSelection.Platform); - var genProject = CreateGenInfo(GenContext.Current.ProjectName, projectTemplate, genQueue); + var genProject = CreateGenInfo(GenContext.Current.ProjectName, projectTemplate, genQueue, false); genProject.Parameters.Add(GenParams.Username, Environment.UserName); genProject.Parameters.Add(GenParams.WizardVersion, string.Concat("v", GenContext.ToolBox.WizardVersion)); @@ -188,14 +188,14 @@ private static ITemplateInfo GetProjectTemplate(string projectType, string frame && t.GetPlatform() == platform); } - private static void AddTemplates(IEnumerable<(string name, ITemplateInfo template)> templates, List genQueue, UserSelection userSelection) + private static void AddTemplates(IEnumerable<(string name, ITemplateInfo template)> templates, List genQueue, UserSelection userSelection, bool newItemGeneration) { foreach (var selectionItem in templates) { if (!genQueue.Any(t => t.Name == selectionItem.name && t.Template.Identity == selectionItem.template.Identity)) { - AddDependencyTemplates(selectionItem, genQueue, userSelection); - var genInfo = CreateGenInfo(selectionItem.name, selectionItem.template, genQueue); + AddDependencyTemplates(selectionItem, genQueue, userSelection, newItemGeneration); + var genInfo = CreateGenInfo(selectionItem.name, selectionItem.template, genQueue, newItemGeneration); genInfo?.Parameters.Add(GenParams.HomePageName, userSelection.HomeName); genInfo?.Parameters.Add(GenParams.ProjectName, GenContext.Current.ProjectName); @@ -211,7 +211,7 @@ private static void AddTemplates(IEnumerable<(string name, ITemplateInfo templat } } - private static void AddDependencyTemplates((string name, ITemplateInfo template) selectionItem, List genQueue, UserSelection userSelection) + private static void AddDependencyTemplates((string name, ITemplateInfo template) selectionItem, List genQueue, UserSelection userSelection, bool newItemGeneration) { var dependencies = GetAllDependencies(selectionItem.template, userSelection.Framework, userSelection.Platform); @@ -223,7 +223,7 @@ private static void AddDependencyTemplates((string name, ITemplateInfo template) { if (!genQueue.Any(t => t.Name == dependencyTemplate.name && t.Template.Identity == dependencyTemplate.template.Identity)) { - var depGenInfo = CreateGenInfo(dependencyTemplate.name, dependencyTemplate.template, genQueue); + var depGenInfo = CreateGenInfo(dependencyTemplate.name, dependencyTemplate.template, genQueue, newItemGeneration); depGenInfo?.Parameters.Add(GenParams.HomePageName, userSelection.HomeName); depGenInfo?.Parameters.Add(GenParams.ProjectName, GenContext.Current.ProjectName); } @@ -235,7 +235,7 @@ private static void AddDependencyTemplates((string name, ITemplateInfo template) } } - private static List AddInCompositionTemplates(List genQueue, UserSelection userSelection) + private static List AddInCompositionTemplates(List genQueue, UserSelection userSelection, bool newItemGeneration) { var compositionCatalog = GetCompositionCatalog(userSelection.Platform).ToList(); var context = new QueryablePropertyDictionary @@ -256,7 +256,7 @@ private static List AddInCompositionTemplates(List genQueue, U if (compositionItem.template.GetLanguage() == userSelection.Language && compositionItem.query.Match(genItem.Template, context)) { - AddTemplate(genItem, compositionQueue, compositionItem.template, userSelection); + AddTemplate(genItem, compositionQueue, compositionItem.template, userSelection, newItemGeneration); } } @@ -276,7 +276,7 @@ private static List AddInCompositionTemplates(List genQueue, U .ToList(); } - private static void AddTemplate(GenInfo mainGenInfo, List queue, ITemplateInfo targetTemplate, UserSelection userSelection) + private static void AddTemplate(GenInfo mainGenInfo, List queue, ITemplateInfo targetTemplate, UserSelection userSelection, bool newItemGeneration) { if (targetTemplate != null) { @@ -285,7 +285,7 @@ private static void AddTemplate(GenInfo mainGenInfo, List queue, ITempl mainGenInfo.Parameters.Add(export.name, export.value); } - var genInfo = CreateGenInfo(mainGenInfo.Name, targetTemplate, queue); + var genInfo = CreateGenInfo(mainGenInfo.Name, targetTemplate, queue, newItemGeneration); genInfo?.Parameters.Add(GenParams.HomePageName, userSelection.HomeName); genInfo?.Parameters.Add(GenParams.ProjectName, GenContext.Current.ProjectName); } @@ -300,7 +300,7 @@ private static void LogOrAlertException(string message) #endif } - private static GenInfo CreateGenInfo(string name, ITemplateInfo template, List queue) + private static GenInfo CreateGenInfo(string name, ITemplateInfo template, List queue, bool newItemGeneration) { var genInfo = new GenInfo { @@ -310,14 +310,19 @@ private static GenInfo CreateGenInfo(string name, ITemplateInfo template, List parameters) { + Parameters.Clear(); foreach (var param in parameters) { if (param.Key == "ticks" && long.TryParse(param.Value, out long ticks)) diff --git a/templates/Uwp/Features/DeepLinking.MVVMLight/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/Features/DeepLinking.MVVMLight/Views/SchemeActivationSamplePage.xaml index cfe32d5fe6..e05b0ed255 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLight/Views/SchemeActivationSamplePage.xaml +++ b/templates/Uwp/Features/DeepLinking.MVVMLight/Views/SchemeActivationSamplePage.xaml @@ -19,14 +19,14 @@ x:Name="ContentArea" Margin="{StaticResource MediumLeftRightMargin}"> - - + + - + x:Uid="SchemeActivationSamplePage_Description" + Style="{StaticResource BodyTextStyle}" + Margin="{StaticResource SmallAllMargin}" /> ; - if (parameters != null) - { - ViewModel.Initialize(parameters); - } - } } } diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/.template.config/template.json b/templates/Uwp/Features/DeepLinking.MVVMLightVB/.template.config/template.json index ab221684e6..600cad4f68 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLightVB/.template.config/template.json +++ b/templates/Uwp/Features/DeepLinking.MVVMLightVB/.template.config/template.json @@ -33,9 +33,6 @@ { "path": ".\\Activation\\SchemeActivationHandler.vb" }, - { - "path": ".\\Assets\\Logo.png" - }, { "path": ".\\ViewModels\\SchemeActivationSampleViewModel.vb" }, diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/ViewModels/SchemeActivationSampleViewModel.vb b/templates/Uwp/Features/DeepLinking.MVVMLightVB/ViewModels/SchemeActivationSampleViewModel.vb index 2bd9dba6d9..d59e3f8fd2 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLightVB/ViewModels/SchemeActivationSampleViewModel.vb +++ b/templates/Uwp/Features/DeepLinking.MVVMLightVB/ViewModels/SchemeActivationSampleViewModel.vb @@ -11,6 +11,7 @@ Namespace ViewModels Public ReadOnly Property Parameters As ObservableCollection(Of String) = New ObservableCollection(Of String)() Public Sub Initialize(parameters As Dictionary(Of String, String)) + Me.Parameters.Clear() Dim ticks As Long = Nothing For Each param In parameters diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/Features/DeepLinking.MVVMLightVB/Views/SchemeActivationSamplePage.xaml index 587bf61c34..e05b0ed255 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Views/SchemeActivationSamplePage.xaml +++ b/templates/Uwp/Features/DeepLinking.MVVMLightVB/Views/SchemeActivationSamplePage.xaml @@ -18,16 +18,15 @@ - - - + + - + x:Uid="SchemeActivationSamplePage_Description" + Style="{StaticResource BodyTextStyle}" + Margin="{StaticResource SmallAllMargin}" /> - - - - - - - - - - - Assets\Icon.png - Param_RootNamespace - - - - - - - - diff --git a/templates/Uwp/Features/DeepLinking.Prism/ViewModels/SchemeActivationSampleViewModel.cs b/templates/Uwp/Features/DeepLinking.Prism/ViewModels/SchemeActivationSampleViewModel.cs index 13b67c8b57..df2fcf574f 100644 --- a/templates/Uwp/Features/DeepLinking.Prism/ViewModels/SchemeActivationSampleViewModel.cs +++ b/templates/Uwp/Features/DeepLinking.Prism/ViewModels/SchemeActivationSampleViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using Prism.Windows.Mvvm; +using Prism.Windows.Navigation; namespace Param_ItemNamespace.ViewModels { @@ -17,8 +18,19 @@ public SchemeActivationSampleViewModel() { } + public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary viewModelState) + { + base.OnNavigatedTo(e, viewModelState); + var parameters = e?.Parameter as Dictionary; + if (parameters != null) + { + Initialize(parameters); + } + } + public void Initialize(Dictionary parameters) { + Parameters.Clear(); foreach (var param in parameters) { if (param.Key == "ticks" && long.TryParse(param.Value, out long ticks)) diff --git a/templates/Uwp/Features/DeepLinking.Prism/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/Features/DeepLinking.Prism/Views/SchemeActivationSamplePage.xaml index ccac545df6..cb0e5538e7 100644 --- a/templates/Uwp/Features/DeepLinking.Prism/Views/SchemeActivationSamplePage.xaml +++ b/templates/Uwp/Features/DeepLinking.Prism/Views/SchemeActivationSamplePage.xaml @@ -20,14 +20,14 @@ x:Name="ContentArea" Margin="{StaticResource MediumLeftRightMargin}"> - - + + - + x:Uid="SchemeActivationSamplePage_Description" + Style="{StaticResource BodyTextStyle}" + Margin="{StaticResource SmallAllMargin}" /> ; - if (parameters != null) - { - ViewModel.Initialize(parameters); - } - } } } diff --git a/templates/Uwp/Features/DeepLinking/.template.config/template.json b/templates/Uwp/Features/DeepLinking/.template.config/template.json index d4e0638fbd..1e9130cc69 100644 --- a/templates/Uwp/Features/DeepLinking/.template.config/template.json +++ b/templates/Uwp/Features/DeepLinking/.template.config/template.json @@ -34,7 +34,10 @@ "path": ".\\Activation\\SchemeActivationHandler.cs" }, { - "path": ".\\Assets\\Logo.png" + "path": ".\\Views\\SchemeActivationSamplePage.xaml" + }, + { + "path": ".\\Views\\SchemeActivationSamplePage.xaml.cs" } ], "symbols": { diff --git a/templates/Uwp/Features/DeepLinking/Assets/Logo.png b/templates/Uwp/Features/DeepLinking/Assets/Logo.png deleted file mode 100644 index a74af74c2a..0000000000 Binary files a/templates/Uwp/Features/DeepLinking/Assets/Logo.png and /dev/null differ diff --git a/templates/Uwp/Features/DeepLinking/Package_postaction.appxmanifest b/templates/Uwp/Features/DeepLinking/Package_postaction.appxmanifest deleted file mode 100644 index 0c5f52c4c7..0000000000 --- a/templates/Uwp/Features/DeepLinking/Package_postaction.appxmanifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - Assets\Icon.png - Param_RootNamespace - - - - - - - - diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml similarity index 81% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml rename to templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml index b308a1a609..9473d8d8e6 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml +++ b/templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml @@ -18,17 +18,16 @@ x:Name="ContentArea" Margin="{StaticResource MediumLeftRightMargin}"> - - + + - + x:Uid="SchemeActivationSamplePage_Description" + Style="{StaticResource BodyTextStyle}" + Margin="{StaticResource SmallAllMargin}" /> diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs b/templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml.cs similarity index 60% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs rename to templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml.cs index fb06bcf504..cc031da56e 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs +++ b/templates/Uwp/Features/DeepLinking/Views/SchemeActivationSamplePage.xaml.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using Param_ItemNamespace.ViewModels; namespace Param_ItemNamespace.Views { @@ -12,21 +11,9 @@ namespace Param_ItemNamespace.Views // your needs and redirected to another of your pages. public sealed partial class SchemeActivationSamplePage : Page { - public SchemeActivationSampleViewModel ViewModel { get; } = new SchemeActivationSampleViewModel(); - public SchemeActivationSamplePage() { InitializeComponent(); } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - var parameters = e.Parameter as Dictionary; - if (parameters != null) - { - ViewModel.Initialize(parameters); - } - } } -} +} \ No newline at end of file diff --git a/templates/Uwp/Features/DeepLinkingVB/.template.config/template.json b/templates/Uwp/Features/DeepLinkingVB/.template.config/template.json index 67cc174240..6107594557 100644 --- a/templates/Uwp/Features/DeepLinkingVB/.template.config/template.json +++ b/templates/Uwp/Features/DeepLinkingVB/.template.config/template.json @@ -34,7 +34,10 @@ "path": ".\\Activation\\SchemeActivationHandler.vb" }, { - "path": ".\\Assets\\Logo.png" + "path": ".\\Views\\SchemeActivationSamplePage.xaml" + }, + { + "path": ".\\Views\\SchemeActivationSamplePage.xaml.vb" } ], "symbols": { diff --git a/templates/Uwp/Features/DeepLinkingVB/Assets/Logo.png b/templates/Uwp/Features/DeepLinkingVB/Assets/Logo.png deleted file mode 100644 index a74af74c2a..0000000000 Binary files a/templates/Uwp/Features/DeepLinkingVB/Assets/Logo.png and /dev/null differ diff --git a/templates/Uwp/Features/DeepLinkingVB/Package_postaction.appxmanifest b/templates/Uwp/Features/DeepLinkingVB/Package_postaction.appxmanifest deleted file mode 100644 index 0c5f52c4c7..0000000000 --- a/templates/Uwp/Features/DeepLinkingVB/Package_postaction.appxmanifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - Assets\Icon.png - Param_RootNamespace - - - - - - - - diff --git a/templates/Uwp/Features/DeepLinkingVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/Features/DeepLinkingVB/Strings/en-us/Resources_postaction.resw deleted file mode 100644 index 18ceb96472..0000000000 --- a/templates/Uwp/Features/DeepLinkingVB/Strings/en-us/Resources_postaction.resw +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - Scheme Activation Sample - Page Title for URI Scheme Example - - - diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml similarity index 81% rename from templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml rename to templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml index c0295747fc..9473d8d8e6 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml +++ b/templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml @@ -18,17 +18,16 @@ x:Name="ContentArea" Margin="{StaticResource MediumLeftRightMargin}"> - - + + - + x:Uid="SchemeActivationSamplePage_Description" + Style="{StaticResource BodyTextStyle}" + Margin="{StaticResource SmallAllMargin}" /> diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb b/templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb similarity index 54% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb rename to templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb index cafd1857d4..62dce346ef 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb +++ b/templates/Uwp/Features/DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb @@ -1,19 +1,9 @@ -Imports Param_ItemNamespace.ViewModels - -Namespace Views +Namespace Views ' TODO WTS: Remove this example page when/if it's not needed. ' This page is an example of how to launch a specific page in response to a protocol launch and pass it a value. ' It is expected that you will delete this page once you have changed the handling of a protocol launch to meet ' your needs and redirected to another of your pages. Public NotInheritable Partial Class SchemeActivationSamplePage Inherits Page - - Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel - - Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) - MyBase.OnNavigatedTo(e) - Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) - ViewModel.Initialize(parameters) - End Sub End Class End Namespace diff --git a/templates/Uwp/Pages/Chart.CodeBehind/Views/ChartViewPage.xaml b/templates/Uwp/Pages/Chart.CodeBehind/Views/ChartViewPage.xaml index 1a41c787fe..13635e76e4 100644 --- a/templates/Uwp/Pages/Chart.CodeBehind/Views/ChartViewPage.xaml +++ b/templates/Uwp/Pages/Chart.CodeBehind/Views/ChartViewPage.xaml @@ -14,32 +14,10 @@ Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}"> - - - - - - - - + - - - - - - - - + diff --git a/templates/Uwp/Pages/Chart.CodeBehind/_postaction.csproj b/templates/Uwp/Pages/Chart.CodeBehind/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Chart.CodeBehind/_postaction.csproj +++ b/templates/Uwp/Pages/Chart.CodeBehind/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Chart.CodeBehindVB/Views/ChartViewPage.xaml b/templates/Uwp/Pages/Chart.CodeBehindVB/Views/ChartViewPage.xaml index 1a41c787fe..13635e76e4 100644 --- a/templates/Uwp/Pages/Chart.CodeBehindVB/Views/ChartViewPage.xaml +++ b/templates/Uwp/Pages/Chart.CodeBehindVB/Views/ChartViewPage.xaml @@ -14,32 +14,10 @@ Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}"> - - - - - - - - + - - - - - - - - + diff --git a/templates/Uwp/Pages/Chart.CodeBehindVB/_postaction.vbproj b/templates/Uwp/Pages/Chart.CodeBehindVB/_postaction.vbproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Chart.CodeBehindVB/_postaction.vbproj +++ b/templates/Uwp/Pages/Chart.CodeBehindVB/_postaction.vbproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Chart.Prism/Views/ChartViewPage.xaml b/templates/Uwp/Pages/Chart.Prism/Views/ChartViewPage.xaml index 0d343a8b23..338fe9310e 100644 --- a/templates/Uwp/Pages/Chart.Prism/Views/ChartViewPage.xaml +++ b/templates/Uwp/Pages/Chart.Prism/Views/ChartViewPage.xaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:tc="using:Telerik.UI.Xaml.Controls.Chart" mc:Ignorable="d"> + @@ -13,32 +14,10 @@ Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}"> - - - - - - - - + - - - - - - - - + diff --git a/templates/Uwp/Pages/Chart.Prism/_postaction.csproj b/templates/Uwp/Pages/Chart.Prism/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Chart.Prism/_postaction.csproj +++ b/templates/Uwp/Pages/Chart.Prism/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Chart/Views/ChartViewPage.xaml b/templates/Uwp/Pages/Chart/Views/ChartViewPage.xaml index b85178a8b9..338fe9310e 100644 --- a/templates/Uwp/Pages/Chart/Views/ChartViewPage.xaml +++ b/templates/Uwp/Pages/Chart/Views/ChartViewPage.xaml @@ -6,40 +6,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:tc="using:Telerik.UI.Xaml.Controls.Chart" mc:Ignorable="d"> + - - - - - - - - - + - - - - - - - - + diff --git a/templates/Uwp/Pages/Chart/_postaction.csproj b/templates/Uwp/Pages/Chart/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Chart/_postaction.csproj +++ b/templates/Uwp/Pages/Chart/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/ChartVB/Views/ChartViewPage.xaml b/templates/Uwp/Pages/ChartVB/Views/ChartViewPage.xaml index b85178a8b9..338fe9310e 100644 --- a/templates/Uwp/Pages/ChartVB/Views/ChartViewPage.xaml +++ b/templates/Uwp/Pages/ChartVB/Views/ChartViewPage.xaml @@ -6,40 +6,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:tc="using:Telerik.UI.Xaml.Controls.Chart" mc:Ignorable="d"> + - - - - - - - - - + - - - - - - - - + diff --git a/templates/Uwp/Pages/ChartVB/_postaction.vbproj b/templates/Uwp/Pages/ChartVB/_postaction.vbproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/ChartVB/_postaction.vbproj +++ b/templates/Uwp/Pages/ChartVB/_postaction.vbproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Grid.CodeBehind/_postaction.csproj b/templates/Uwp/Pages/Grid.CodeBehind/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Grid.CodeBehind/_postaction.csproj +++ b/templates/Uwp/Pages/Grid.CodeBehind/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Grid.CodeBehindVB/_postaction.vbproj b/templates/Uwp/Pages/Grid.CodeBehindVB/_postaction.vbproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Grid.CodeBehindVB/_postaction.vbproj +++ b/templates/Uwp/Pages/Grid.CodeBehindVB/_postaction.vbproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Grid.Prism/_postaction.csproj b/templates/Uwp/Pages/Grid.Prism/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Grid.Prism/_postaction.csproj +++ b/templates/Uwp/Pages/Grid.Prism/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/Grid/_postaction.csproj b/templates/Uwp/Pages/Grid/_postaction.csproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/Grid/_postaction.csproj +++ b/templates/Uwp/Pages/Grid/_postaction.csproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/Pages/GridVB/_postaction.vbproj b/templates/Uwp/Pages/GridVB/_postaction.vbproj index a232cd5134..1860c01902 100644 --- a/templates/Uwp/Pages/GridVB/_postaction.vbproj +++ b/templates/Uwp/Pages/GridVB/_postaction.vbproj @@ -5,6 +5,6 @@ - 1.0.1 + 1.0.1.1 diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/.template.config/template.json b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/.template.config/template.json index 31929ae108..c699099ec9 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/.template.config/template.json +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CaliburnMicro", + "name": "CaliburnMicro.DeepLinking", "tags": { "language": "C#", "type": "item", @@ -17,12 +17,6 @@ "PrimaryOutputs": [ { "path": ".\\ViewModels\\SchemeActivationSampleViewModel.cs" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml.cs" } ], "symbols": { diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs index 6e198ccf62..7143fbc060 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs @@ -19,6 +19,7 @@ public SchemeActivationSampleViewModel() public void Initialize(Dictionary parameters) { + Parameters.Clear(); foreach (var param in parameters) { if (param.Key == "ticks" && long.TryParse(param.Value, out long ticks)) diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs deleted file mode 100644 index 0ad3f10a55..0000000000 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -using Param_ItemNamespace.ViewModels; - -namespace Param_ItemNamespace.Views -{ - // TODO WTS: Remove this sample page when/if it's not needed. - // This page is an sample of how to launch a specific page in response to a protocol launch and pass it a value. - // It is expected that you will delete this page once you have changed the handling of a protocol launch to meet - // your needs and redirected to another of your pages. - public sealed partial class SchemeActivationSamplePage : Page - { - private SchemeActivationSampleViewModel ViewModel - { - get { return DataContext as SchemeActivationSampleViewModel; } - } - - public SchemeActivationSamplePage() - { - InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - var parameters = e.Parameter as Dictionary; - if (parameters != null) - { - ViewModel.Initialize(parameters); - } - } - } -} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..71e294bfff --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,11 @@ + + + + ItemsSource="{x:Bind ViewModel.Parameters}" + + ItemTemplate="{StaticResource ActivationParameterDateTemplate}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..862510c159 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,20 @@ +//{[{ +using Param_ItemNamespace.ViewModels; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class SchemeActivationSamplePage : Page + { +//{[{ + private SchemeActivationSampleViewModel ViewModel + { + get { return DataContext as SchemeActivationSampleViewModel; } + } + +//}]} + public SchemeActivationSamplePage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/.template.config/template.json similarity index 83% rename from templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json rename to templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/.template.config/template.json index ab079c2a1a..f21926f4c4 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CaliburnMicro.Activavtion.BlankOrSplitView", + "name": "CaliburnMicro.DeepLinking.Blank", "tags": { "language": "C#", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.DeepLinking & $projectType == Blank|SplitView" + "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.DeepLinking & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs similarity index 100% rename from templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs diff --git a/templates/Uwp/Features/DeepLinking.Prism/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw similarity index 59% rename from templates/Uwp/Features/DeepLinking.Prism/Strings/en-us/Resources_postaction.resw rename to templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw index 18ceb96472..aaa1280d40 100644 --- a/templates/Uwp/Features/DeepLinking.Prism/Strings/en-us/Resources_postaction.resw +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw @@ -1,12 +1,12 @@  - + - Scheme Activation Sample + SchemeActivationSample Page Title for URI Scheme Example diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/.template.config/template.json b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/.template.config/template.json new file mode 100644 index 0000000000..ccffec0739 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.DeepLinking.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.DeepLinking & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs similarity index 94% rename from templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs index d6b562f4b1..2c30ae8802 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs @@ -26,7 +26,7 @@ protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs arg else if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page - _navigationService.For().Navigate(); + _navigationService.For().Navigate(); } await Task.CompletedTask; diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..d0858328bc --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/.template.config/template.json similarity index 86% rename from templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json rename to templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/.template.config/template.json index 1f5011b02f..0b4fcf3c77 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CaliburnMicro.Activavtion.TabbedPivot", + "name": "CaliburnMicro.DeepLinking.TabbedPivot", "tags": { "language": "C#", "type": "item", @@ -15,6 +15,9 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ + { + "path": ".\\Helpers\\IPivotActivationPage.cs" + } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs new file mode 100644 index 0000000000..1f7e85d789 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs @@ -0,0 +1,49 @@ +//{[{ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Caliburn.Micro; +using Param_ItemNamespace.Views; +using Param_ItemNamespace.ViewModels; +//}]} +namespace Param_ItemNamespace.Activation +{ + internal class SchemeActivationHandler : ActivationHandler + { +//{[{ + private INavigationService _navigationService; + + public SchemeActivationHandler(INavigationService navigationService) + { + _navigationService = navigationService; + } + + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs args) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(args.Uri); + if (data.IsValid) + { + var frame = Window.Current.Content as Frame; + if (frame.Content is PivotPage pivotPage && pivotPage.DataContext is PivotViewModel viewModel) + { + viewModel.ActivationData = data; + await viewModel.InitializeFromSchemeActivationAsync(); + } + else + { + _navigationService.Navigate(typeof(PivotPage), data); + } + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + _navigationService.For().Navigate(); + } + + await Task.CompletedTask; + } + +//}]} + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Helpers/IPivotActivationPage.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Helpers/IPivotActivationPage.cs new file mode 100644 index 0000000000..5593191c0b --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Helpers/IPivotActivationPage.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Param_ItemNamespace.Helpers +{ + public interface IPivotActivationPage + { + Task OnPivotActivatedAsync(Dictionary parameters); + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..eb676c9384 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,9 @@ + + + + + SchemeActivationSample + Pivot item header for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/ViewModels/PivotViewModel_postaction.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/ViewModels/PivotViewModel_postaction.cs new file mode 100644 index 0000000000..da881c302f --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/ViewModels/PivotViewModel_postaction.cs @@ -0,0 +1,43 @@ +//{[{ +using System.Linq; +using System.Threading.Tasks; +using Param_ItemNamespace.Activation; +//}]} +namespace Param_ItemNamespace.ViewModels +{ + public class PivotViewModel : Conductor.Collection.OneActive + { +//{[{ + public SchemeActivationData ActivationData { get; set; } + +//}]} + protected override void OnInitialize() + { + //^^ + //{[{ + Items.Add(new SchemeActivationSampleViewModel { DisplayName = "PivotItem_SchemeActivationSample/Header".GetLocalized() }); + //}]} + } + +//{[{ + protected override async void OnViewReady(object view) + { + base.OnViewReady(view); + if (ActivationData != null) + { + await InitializeFromSchemeActivationAsync(); + } + } + + public async Task InitializeFromSchemeActivationAsync() + { + var selectedScreen = Items.FirstOrDefault(s => s.GetView().GetType() == ActivationData.PageType); + ActivateItem(selectedScreen); + if (selectedScreen.GetView() is IPivotActivationPage page) + { + await page.OnPivotActivatedAsync(ActivationData.Parameters); + } + } +//}]} + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs new file mode 100644 index 0000000000..276e24ffee --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs @@ -0,0 +1,27 @@ +//{[{ +using Param_ItemNamespace.Activation; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class PivotPage : Page + { +//{[{ + private PivotViewModel ViewModel + { + get { return DataContext as PivotViewModel; } + } +//}]} + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); +//{[{ + if (e.Parameter is SchemeActivationData activationData) + { + ViewModel.ActivationData = activationData; + } + +//}]} + } + } +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..87eebb9268 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +//{[{ +using System.Threading.Tasks; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + public async Task OnPivotActivatedAsync(Dictionary parameters) + { + ViewModel.Initialize(parameters); + await Task.CompletedTask; + } +//}]} +} diff --git a/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs new file mode 100644 index 0000000000..11de633589 --- /dev/null +++ b/templates/Uwp/_composition/CaliburnMicro/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs @@ -0,0 +1,3 @@ +public sealed partial class SchemeActivationSamplePage : Page +^^^-searchabove-replacebelow-vvv +public sealed partial class SchemeActivationSamplePage : Page, IPivotActivationPage diff --git a/templates/Uwp/_composition/CaliburnMicro/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs b/templates/Uwp/_composition/CaliburnMicro/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs index 8824c88da9..d49e815d94 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs +++ b/templates/Uwp/_composition/CaliburnMicro/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs @@ -24,10 +24,10 @@ protected override void OnDetaching() private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetView() as IPivotPage).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetView() as IPivotPage).FirstOrDefault(); if (removedItem != null) { diff --git a/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Behaviors/PivotBehavior.cs b/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Behaviors/PivotBehavior.cs index 84996100ac..7a9ae4ca00 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Behaviors/PivotBehavior.cs +++ b/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Behaviors/PivotBehavior.cs @@ -3,9 +3,9 @@ using Microsoft.Xaml.Interactivity; using Windows.UI.Xaml.Controls; using Caliburn.Micro; -using wts.ItemName.Helpers; +using Param_ItemNamespace.Helpers; -namespace wts.ItemName.Behaviors +namespace Param_ItemNamespace.Behaviors { public class PivotBehavior : Behavior { @@ -24,10 +24,10 @@ protected override void OnDetaching() private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetView() as IPivotPage).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetView() as IPivotPage).FirstOrDefault(); if (removedItem != null) { @@ -39,15 +39,5 @@ private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e await addedItem?.OnPivotSelectedAsync(); } } - - private static IPivotPage GetPivotPage(Screen screen) - { - if (screen.GetView() is IPivotPage pivotPage) - { - return pivotPage; - } - - return null; - } } } diff --git a/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs index 0c9c508c91..dad52b3c53 100644 --- a/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs +++ b/templates/Uwp/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -1,6 +1,7 @@ -using wts.ItemName.ViewModels; +using System.Threading.Tasks; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using wts.ItemName.ViewModels; namespace wts.ItemName.Views { @@ -15,5 +16,11 @@ public PivotPage() InitializeComponent(); } + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await Task.CompletedTask; + } } } diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/.template.config/template.json index 7eb341ea10..1d1a1a9c2e 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CodeBehind", + "name": "CodeBehind.DeepLinking", "tags": { "language": "C#", "type": "item", @@ -15,12 +15,6 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml.cs" - } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..293e3405db --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,11 @@ + + + + ItemsSource="{x:Bind Parameters}" + + ItemTemplate="{StaticResource ActivationParameterDateTemplate}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs similarity index 56% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs index a7a45e33f4..cc04bdd8a0 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml.cs +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -1,36 +1,26 @@ -using System; -using System.Collections.Generic; +//{[{ using System.Collections.ObjectModel; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - +using System.ComponentModel; +using System.Runtime.CompilerServices; +//}]} namespace Param_ItemNamespace.Views { - // TODO WTS: Remove this sample page when/if it's not needed. - // This page is an sample of how to launch a specific page in response to a protocol launch and pass it a value. - // It is expected that you will delete this page once you have changed the handling of a protocol launch to meet - // your needs and redirected to another of your pages. public sealed partial class SchemeActivationSamplePage : Page { +//{[{ public ObservableCollection Parameters { get; } = new ObservableCollection(); +//}]} public SchemeActivationSamplePage() { InitializeComponent(); } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - var parameters = e.Parameter as Dictionary; - if (parameters != null) - { - Initialize(parameters); - } - } +//^^ +//{[{ public void Initialize(Dictionary parameters) { + Parameters.Clear(); foreach (var param in parameters) { if (param.Key == "ticks" && long.TryParse(param.Value, out long ticks)) @@ -44,5 +34,21 @@ public void Initialize(Dictionary parameters) } } } + + public event PropertyChangedEventHandler PropertyChanged; + + private void Set(ref T storage, T value, [CallerMemberName]string propertyName = null) + { + if (Equals(storage, value)) + { + return; + } + + storage = value; + OnPropertyChanged(propertyName); + } + + private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); +//}]} } } diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_searchreplace.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_searchreplace.xaml.cs new file mode 100644 index 0000000000..90fb4f31cb --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking/Views/SchemeActivationSamplePage_searchreplace.xaml.cs @@ -0,0 +1,3 @@ +public sealed partial class SchemeActivationSamplePage : Page +^^^-searchabove-replacebelow-vvv +public sealed partial class SchemeActivationSamplePage : Page, INotifyPropertyChanged diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/.template.config/template.json index 81233e9522..93ca7a00f7 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/.template.config/template.json @@ -15,12 +15,6 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml.vb" - } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml deleted file mode 100644 index d868733f00..0000000000 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..293e3405db --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,11 @@ + + + + ItemsSource="{x:Bind Parameters}" + + ItemTemplate="{StaticResource ActivationParameterDateTemplate}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb similarity index 74% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb index 1e974e6d54..b785ccb27d 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml.vb +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -1,21 +1,23 @@ -Namespace Views - ' TODO WTS: Remove this example page when/if it's not needed. - ' This page is an example of how to launch a specific page in response to a protocol launch and pass it a value. - ' It is expected that you will delete this page once you have changed the handling of a protocol launch to meet - ' your needs and redirected to another of your pages. +'{[{ +'}]} +Namespace Views Public NotInheritable Partial Class SchemeActivationSamplePage Inherits Page +'{[{ Implements INotifyPropertyChanged Public ReadOnly Property Parameters As ObservableCollection(Of String) = New ObservableCollection(Of String)() Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) MyBase.OnNavigatedTo(e) - Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) - Initialize(parameters) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + Initialize(parameters) + End If End Sub Private Sub Initialize(parameters As Dictionary(Of String, String)) + Me.Parameters.Clear() Dim ticks As Long = Nothing For Each param In parameters @@ -42,5 +44,6 @@ Private Sub OnPropertyChanged(propertyName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) End Sub +'}]} End Class -End Namespace +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/.template.config/template.json similarity index 83% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/.template.config/template.json index 24dca18314..551917e991 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CodeBehind.Activavtion.BlankOrSplitView", + "name": "CodeBehind.DeepLinking.Blank", "tags": { "language": "C#", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking & $projectType == Blank|SplitView" + "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs similarity index 100% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs diff --git a/templates/Uwp/Features/DeepLinking/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw similarity index 59% rename from templates/Uwp/Features/DeepLinking/Strings/en-us/Resources_postaction.resw rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw index 18ceb96472..aaa1280d40 100644 --- a/templates/Uwp/Features/DeepLinking/Strings/en-us/Resources_postaction.resw +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw @@ -1,12 +1,12 @@  - + - Scheme Activation Sample + SchemeActivationSample Page Title for URI Scheme Example diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..e52dd50902 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/.template.config/template.json similarity index 85% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/.template.config/template.json index d375d6b420..cfde47bfaa 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CodeBehind.Activavtion.BlankOrSplitView.VB", + "name": "CodeBehind.DeepLinking.Blank.VB", "tags": { "language": "VisualBasic", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking.VB & $projectType == Blank|SplitView" + "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking.VB & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb similarity index 100% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..aaa1280d40 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Page Title for URI Scheme Example + + + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..d33cfefbfb --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,15 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'{[{ + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/.template.config/template.json new file mode 100644 index 0000000000..8c386730d5 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "CodeBehind.DeepLinking.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs similarity index 100% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..e52dd50902 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..d0858328bc --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/.template.config/template.json new file mode 100644 index 0000000000..7a41462f27 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/.template.config/template.json @@ -0,0 +1,37 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "CodeBehind.DeepLinking.SplitView.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CodeBehind & identity == wts.Feat.DeepLinking.VB & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + }, + "wts.homePageName": { + "type": "parameter", + "replaces": "Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb similarity index 90% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb index 6032210bf3..4d3dc7cec4 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb @@ -1,6 +1,6 @@ Namespace Activation Friend Class SchemeActivationHandler - Inherits ActivationHandler(Of ProtocolActivatedEventArgs) + Inherits ActivationHandler(Of ProtocolActivatedEventArgs) '{[{ ' By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' @@ -10,7 +10,7 @@ If data.IsValid Then NavigationService.Navigate(data.PageType, data.Parameters) ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then - NavigationService.Navigate(GetType(Views.PivotPage)) + NavigationService.Navigate(GetType(Views.Param_HomeNamePage)) End If Await Task.CompletedTask End Function diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..504c1c23de --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,15 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'{[{ + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..4d9742f976 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/.template.config/template.json similarity index 91% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/.template.config/template.json index d639d90623..abafbb181b 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CodeBehind.Activavtion.TabbedPivot", + "name": "CodeBehind.DeepLinking.TabbedPivot", "tags": { "language": "C#", "type": "item", diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs new file mode 100644 index 0000000000..b1b7fb32b6 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs @@ -0,0 +1,39 @@ +//{[{ +using Param_ItemNamespace.Views; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +//}]} +namespace Param_ItemNamespace.Activation +{ + internal class SchemeActivationHandler : ActivationHandler + { +//{[{ + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs args) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(args.Uri); + if (data.IsValid) + { + var frame = Window.Current.Content as Frame; + if (frame.Content is PivotPage pivotPage) + { + await pivotPage.InitializeFromSchemeActivationAsync(data); + } + else + { + NavigationService.Navigate(typeof(PivotPage), data); + } + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + NavigationService.Navigate(typeof(Views.PivotPage)); + } + + await Task.CompletedTask; + } + +//}]} + } +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs new file mode 100644 index 0000000000..ba27c9008e --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs @@ -0,0 +1,35 @@ +//{[{ +using System.Linq; +using Param_ItemNamespace.Activation; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class PivotPage : Page + { + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); +//{[{ + if (e.Parameter is SchemeActivationData data) + { + await InitializeFromSchemeActivationAsync(data); + } + +//}]} + } + +//{[{ + public async Task InitializeFromSchemeActivationAsync(SchemeActivationData schemeActivationData) + { + var selected = pivot.Items.Cast() + .FirstOrDefault(i => i.IsOfPageType(schemeActivationData.PageType)); + + var page = selected?.GetPage(); + + pivot.SelectedItem = selected; + await page?.OnPivotActivatedAsync(schemeActivationData.Parameters); + } +//}]} + } +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..ea1abf4da3 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +//{[{ +using System.Threading.Tasks; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + public async Task OnPivotActivatedAsync(Dictionary parameters) + { + Initialize(parameters); + await Task.CompletedTask; + } +//}]} +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs new file mode 100644 index 0000000000..11de633589 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs @@ -0,0 +1,3 @@ +public sealed partial class SchemeActivationSamplePage : Page +^^^-searchabove-replacebelow-vvv +public sealed partial class SchemeActivationSamplePage : Page, IPivotActivationPage diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json similarity index 92% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json rename to templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json index d6e01ee0cc..7406a2c566 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.CodeBehind.Activavtion.TabbedPivot.VB", + "name": "CodeBehind.DeepLinking.TabbedPivot.VB", "tags": { "language": "VisualBasic", "type": "item", diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb new file mode 100644 index 0000000000..648a92c5f9 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb @@ -0,0 +1,28 @@ +'{[{ +Imports Param_ItemNamespace.Views +'}]} +Namespace Activation + Friend Class SchemeActivationHandler + Inherits ActivationHandler(Of ProtocolActivatedEventArgs) + '{[{ + + ' By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + Protected Overrides Async Function HandleInternalAsync(args As ProtocolActivatedEventArgs) As Task + ' Create data from activation Uri in ProtocolActivatedEventArgs + Dim data = New SchemeActivationData(args.Uri) + If data.IsValid Then + Dim frame = TryCast(Window.Current.Content, Frame) + Dim pivotPage = TryCast(frame.Content, PivotPage) + If pivotPage IsNot Nothing Then + Await pivotPage.InitializeFromSchemeActivationAsync(data) + Else + NavigationService.Navigate(GetType(Views.PivotPage), data) + End If + ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then + NavigationService.Navigate(GetType(Views.PivotPage)) + End If + Await Task.CompletedTask + End Function + '}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb new file mode 100644 index 0000000000..d904a54e08 --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb @@ -0,0 +1,29 @@ +'{[{ +Imports System.Linq +Imports Param_ItemNamespace.Activation +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class PivotPage + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) +'{[{ + Dim data = TryCast(e.Parameter, SchemeActivationData) + If data IsNot Nothing + Await InitializeFromSchemeActivationAsync(data) + End If + +'}]} + Await Task.CompletedTask + End Sub + +'{[{ + Public Async Function InitializeFromSchemeActivationAsync(schemeActivationData As SchemeActivationData) As Task + Dim selected = pivot.Items.Cast(Of PivotItem)().FirstOrDefault(Function(i) i.IsOfPageType(schemeActivationData.PageType)) + Dim page = selected?.GetPage(Of IPivotActivationPage)() + pivot.SelectedItem = selected + Await page?.OnPivotActivatedAsync(schemeActivationData.Parameters) + End Function +'}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..8c735dc5fa --- /dev/null +++ b/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,18 @@ +'{[{ +Imports System.Threading.Tasks +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page + Implements INotifyPropertyChanged +'{[{ + Implements IPivotActivationPage + + Public Async Function OnPivotActivatedAsync(parameters As Dictionary(Of String, String)) As Task Implements IPivotActivationPage.OnPivotActivatedAsync + Initialize(parameters) + Await Task.CompletedTask + End Function +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml index 6817d2ade5..a604e946e2 100644 --- a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml.cs index e7ace230aa..58fe34bf57 100644 --- a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml.cs +++ b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; @@ -14,5 +15,11 @@ public PivotPage() NavigationCacheMode = NavigationCacheMode.Required; InitializeComponent(); } + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await Task.CompletedTask; + } } } diff --git a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml index 6817d2ade5..a604e946e2 100644 --- a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml.vb b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml.vb index 83517452b0..494fb23f53 100644 --- a/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml.vb +++ b/templates/Uwp/_composition/CodeBehind/Project.TabbedPivotVB/Views/PivotPage.xaml.vb @@ -9,5 +9,10 @@ ' https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh771188.aspx NavigationCacheMode = NavigationCacheMode.Required End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + Await Task.CompletedTask + End Sub End Class End Namespace diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/.template.config/template.json index 4ea5c35856..53fded4ceb 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MvvmBasic", + "name": "MvvmBasic.DeepLinking", "tags": { "language": "C#", "type": "item", @@ -17,12 +17,6 @@ "PrimaryOutputs": [ { "path": ".\\ViewModels\\SchemeActivationSampleViewModel.cs" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml.cs" } ], "symbols": { diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs index 6cfcb6552e..ea21314abd 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/ViewModels/SchemeActivationSampleViewModel.cs @@ -19,6 +19,7 @@ public SchemeActivationSampleViewModel() public void Initialize(Dictionary parameters) { + Parameters.Clear(); foreach (var param in parameters) { if (param.Key == "ticks" && long.TryParse(param.Value, out long ticks)) diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml deleted file mode 100644 index c0295747fc..0000000000 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..71e294bfff --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,11 @@ + + + + ItemsSource="{x:Bind ViewModel.Parameters}" + + ItemTemplate="{StaticResource ActivationParameterDateTemplate}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..396f5b0191 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,17 @@ +//{[{ +using Param_ItemNamespace.ViewModels; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class SchemeActivationSamplePage : Page + { +//{[{ + public SchemeActivationSampleViewModel ViewModel { get; } = new SchemeActivationSampleViewModel(); + +//}]} + public SchemeActivationSamplePage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/.template.config/template.json index c639b1feb8..6bbf9f3733 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/.template.config/template.json @@ -17,12 +17,6 @@ "PrimaryOutputs": [ { "path": ".\\ViewModels\\SchemeActivationSampleViewModel.vb" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml" - }, - { - "path": ".\\Views\\SchemeActivationSamplePage.xaml.vb" } ], "symbols": { diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/ViewModels/SchemeActivationSampleViewModel.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/ViewModels/SchemeActivationSampleViewModel.vb index 5ff7ae92f9..bcf8784c63 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/ViewModels/SchemeActivationSampleViewModel.vb +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/ViewModels/SchemeActivationSampleViewModel.vb @@ -11,6 +11,7 @@ Namespace ViewModels Public ReadOnly Property Parameters As ObservableCollection(Of String) = New ObservableCollection(Of String)() Public Sub Initialize(parameters As Dictionary(Of String, String)) + Me.Parameters.Clear() Dim ticks As Long = Nothing For Each param In parameters diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml deleted file mode 100644 index a3e63a968b..0000000000 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage.xaml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..71e294bfff --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,11 @@ + + + + ItemsSource="{x:Bind ViewModel.Parameters}" + + ItemTemplate="{StaticResource ActivationParameterDateTemplate}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..ce5b08147c --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinkingVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,13 @@ +'{[{ +Imports Param_ItemNamespace.ViewModels +'}]} + +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'{[{ + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/.template.config/template.json similarity index 84% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/.template.config/template.json index d40f294f73..1239f82c23 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MvvmBasic.Activavtion.BlankOrSplitView", + "name": "MvvmBasic.DeepLinking.Blank", "tags": { "language": "C#", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking & $projectType == Blank|SplitView" + "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs similarity index 92% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs index a64177d3fb..140e169917 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs @@ -18,7 +18,7 @@ protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs arg else if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page - NavigationService.Navigate(typeof(Views.PivotPage)); + NavigationService.Navigate(typeof(Views.Param_HomeNamePage)); } await Task.CompletedTask; diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..aaa1280d40 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Page Title for URI Scheme Example + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/.template.config/template.json similarity index 83% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/.template.config/template.json index b46b451954..33eb8ea176 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MvvmBasic.Activavtion.BlankOrSplitView.VB", + "name": "MvvmBasic.DeepLinking.Blank.VB", "tags": { "language": "VisualBasic", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking.VB & $projectType == Blank|SplitView" + "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking.VB & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb similarity index 100% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..aaa1280d40 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Page Title for URI Scheme Example + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..78dae72fbf --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,17 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'{[{ + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + ViewModel.Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/.template.config/template.json new file mode 100644 index 0000000000..a8f8bd4925 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MvvmBasic.DeepLinking.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs similarity index 92% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs index a64177d3fb..140e169917 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs @@ -18,7 +18,7 @@ protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs arg else if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page - NavigationService.Navigate(typeof(Views.PivotPage)); + NavigationService.Navigate(typeof(Views.Param_HomeNamePage)); } await Task.CompletedTask; diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..d0858328bc --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/.template.config/template.json new file mode 100644 index 0000000000..8f03cb0e3d --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MvvmBasic.DeepLinking.SplitView.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == MVVMBasic & identity == wts.Feat.DeepLinking.VB & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb similarity index 91% rename from templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb index 6032210bf3..ab6ddab5d6 100644 --- a/templates/Uwp/_composition/CodeBehind/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb @@ -10,7 +10,7 @@ If data.IsValid Then NavigationService.Navigate(data.PageType, data.Parameters) ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then - NavigationService.Navigate(GetType(Views.PivotPage)) + NavigationService.Navigate(GetType(Views.Param_HomeNamePage)) End If Await Task.CompletedTask End Function diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..1d0463f8d7 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,17 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'^^ +'{[{ + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + ViewModel.Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..4d9742f976 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/.template.config/template.json similarity index 91% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/.template.config/template.json index a99b56cc6b..84e4b28dbc 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MvvmBasic.Activavtion.TabbedPivot", + "name": "MvvmBasic.DeepLinking.TabbedPivot", "tags": { "language": "C#", "type": "item", diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs new file mode 100644 index 0000000000..0e2853c86f --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs @@ -0,0 +1,39 @@ +//{[{ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Views; +//}]} +namespace Param_ItemNamespace.Activation +{ + internal class SchemeActivationHandler : ActivationHandler + { +//{[{ + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs args) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(args.Uri); + if (data.IsValid) + { + var frame = Window.Current.Content as Frame; + if (frame.Content is PivotPage pivotPage) + { + await pivotPage.InitializeFromSchemeActivationAsync(data); + } + else + { + NavigationService.Navigate(typeof(PivotPage), data); + } + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + NavigationService.Navigate(typeof(Views.PivotPage)); + } + + await Task.CompletedTask; + } + +//}]} + } +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs new file mode 100644 index 0000000000..ba27c9008e --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs @@ -0,0 +1,35 @@ +//{[{ +using System.Linq; +using Param_ItemNamespace.Activation; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class PivotPage : Page + { + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); +//{[{ + if (e.Parameter is SchemeActivationData data) + { + await InitializeFromSchemeActivationAsync(data); + } + +//}]} + } + +//{[{ + public async Task InitializeFromSchemeActivationAsync(SchemeActivationData schemeActivationData) + { + var selected = pivot.Items.Cast() + .FirstOrDefault(i => i.IsOfPageType(schemeActivationData.PageType)); + + var page = selected?.GetPage(); + + pivot.SelectedItem = selected; + await page?.OnPivotActivatedAsync(schemeActivationData.Parameters); + } +//}]} + } +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..87eebb9268 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +//{[{ +using System.Threading.Tasks; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + public async Task OnPivotActivatedAsync(Dictionary parameters) + { + ViewModel.Initialize(parameters); + await Task.CompletedTask; + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs new file mode 100644 index 0000000000..11de633589 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs @@ -0,0 +1,3 @@ +public sealed partial class SchemeActivationSamplePage : Page +^^^-searchabove-replacebelow-vvv +public sealed partial class SchemeActivationSamplePage : Page, IPivotActivationPage diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json similarity index 91% rename from templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json rename to templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json index 6d726285d4..c5af7a07c1 100644 --- a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json @@ -3,7 +3,7 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MvvmBasic.Activavtion.TabbedPivot.VB", + "name": "MvvmBasic.DeepLinking.TabbedPivot.VB", "tags": { "language": "VisualBasic", "type": "item", diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb new file mode 100644 index 0000000000..648a92c5f9 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb @@ -0,0 +1,28 @@ +'{[{ +Imports Param_ItemNamespace.Views +'}]} +Namespace Activation + Friend Class SchemeActivationHandler + Inherits ActivationHandler(Of ProtocolActivatedEventArgs) + '{[{ + + ' By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + Protected Overrides Async Function HandleInternalAsync(args As ProtocolActivatedEventArgs) As Task + ' Create data from activation Uri in ProtocolActivatedEventArgs + Dim data = New SchemeActivationData(args.Uri) + If data.IsValid Then + Dim frame = TryCast(Window.Current.Content, Frame) + Dim pivotPage = TryCast(frame.Content, PivotPage) + If pivotPage IsNot Nothing Then + Await pivotPage.InitializeFromSchemeActivationAsync(data) + Else + NavigationService.Navigate(GetType(Views.PivotPage), data) + End If + ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then + NavigationService.Navigate(GetType(Views.PivotPage)) + End If + Await Task.CompletedTask + End Function + '}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb new file mode 100644 index 0000000000..d904a54e08 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb @@ -0,0 +1,29 @@ +'{[{ +Imports System.Linq +Imports Param_ItemNamespace.Activation +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class PivotPage + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) +'{[{ + Dim data = TryCast(e.Parameter, SchemeActivationData) + If data IsNot Nothing + Await InitializeFromSchemeActivationAsync(data) + End If + +'}]} + Await Task.CompletedTask + End Sub + +'{[{ + Public Async Function InitializeFromSchemeActivationAsync(schemeActivationData As SchemeActivationData) As Task + Dim selected = pivot.Items.Cast(Of PivotItem)().FirstOrDefault(Function(i) i.IsOfPageType(schemeActivationData.PageType)) + Dim page = selected?.GetPage(Of IPivotActivationPage)() + pivot.SelectedItem = selected + Await page?.OnPivotActivatedAsync(schemeActivationData.Parameters) + End Function +'}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..c60c455381 --- /dev/null +++ b/templates/Uwp/_composition/MVVMBasic/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,21 @@ +'{[{ +Imports System.Threading.Tasks +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'{[{ + Implements IPivotActivationPage +'}]} + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'{[{ + + Public Async Function OnPivotActivatedAsync(parameters As Dictionary(Of String, String)) As Task Implements IPivotActivationPage.OnPivotActivatedAsync + ViewModel.Initialize(parameters) + Await Task.CompletedTask + End Function +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml index 6817d2ade5..a604e946e2 100644 --- a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml.cs index 711d40fc89..b0ddb9ae9c 100644 --- a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml.cs +++ b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using wts.ItemName.ViewModels; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; @@ -18,5 +19,11 @@ public PivotPage() DataContext = ViewModel; InitializeComponent(); } + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await Task.CompletedTask; + } } } diff --git a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml index 6817d2ade5..a604e946e2 100644 --- a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml.vb b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml.vb index e60f238ad4..b8a9828f71 100644 --- a/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml.vb +++ b/templates/Uwp/_composition/MVVMBasic/Project.TabbedPivotVB/Views/PivotPage.xaml.vb @@ -14,5 +14,10 @@ Namespace Views NavigationCacheMode = NavigationCacheMode.Required DataContext = ViewModel End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + Await Task.CompletedTask + End Sub End Class End Namespace diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json deleted file mode 100644 index 0fe067ed64..0000000000 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitView/.template.config/template.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "author": "Microsoft Community", - "classifications": [ - "Universal" - ], - "name": "wts.Feat.DeepLinking.MVVMLight.Activavtion.BlankOrSplitView", - "tags": { - "language": "C#", - "type": "item", - "wts.type": "composition", - "wts.platform" : "Uwp", - "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMLight & identity == wts.Feat.DeepLinking.MVVMLight & $projectType == Blank|SplitView" - }, - "sourceName": "wts.ItemName", - "preferNameDirectory": true, - "PrimaryOutputs": [ - ], - "symbols": { - "wts.rootNamespace": { - "type": "parameter", - "replaces": "Param_RootNamespace" - }, - "wts.itemNamespace": { - "type": "parameter", - "replaces": "Param_ItemNamespace" - }, - "wts.homePageName": { - "type":"parameter", - "replaces":"Param_HomeName" - } - } -} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json deleted file mode 100644 index 87038a1c5e..0000000000 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/.template.config/template.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "author": "Microsoft Community", - "classifications": [ - "Universal" - ], - "name": "wts.Feat.DeepLinking.MVVMLight.Activavtion.TabbedPivot", - "tags": { - "language": "C#", - "type": "item", - "wts.type": "composition", - "wts.platform" : "Uwp", - "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMLight & identity == wts.Feat.DeepLinking.MVVMLight & $projectType == TabbedPivot" - }, - "sourceName": "wts.ItemName", - "preferNameDirectory": true, - "PrimaryOutputs": [ - ], - "symbols": { - "wts.rootNamespace": { - "type": "parameter", - "replaces": "Param_RootNamespace" - }, - "wts.itemNamespace": { - "type": "parameter", - "replaces": "Param_ItemNamespace" - }, - "wts.homePageName": { - "type":"parameter", - "replaces":"Param_HomeName" - } - } -} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/.template.config/template.json new file mode 100644 index 0000000000..18b4597f7d --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.DeepLinking.Blank", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight & $projectType == Blank" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs similarity index 100% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitView/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Activation/SchemeActivationHandler_postaction.cs diff --git a/templates/Uwp/Features/DeepLinking.MVVMLight/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw similarity index 87% rename from templates/Uwp/Features/DeepLinking.MVVMLight/Strings/en-us/Resources_postaction.resw rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw index 18ceb96472..44b5757a7d 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLight/Strings/en-us/Resources_postaction.resw +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw @@ -6,7 +6,7 @@ - Scheme Activation Sample + SchemeActivationSample Page Title for URI Scheme Example diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/.template.config/template.json similarity index 75% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/.template.config/template.json index 1eed9e821b..83dd3c66ed 100644 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MVVMLight.Activavtion.TabbedPivot.VB", + "name": "MVVMLight.DeepLinking.Blank.VB", "tags": { "language": "VisualBasic", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMLight & identity == wts.Feat.DeepLinking.MVVMLight.VB & $projectType == TabbedPivot" + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight.VB & $projectType == Blank" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb similarity index 100% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Activation/SchemeActivationHandler_postaction.vb diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw similarity index 87% rename from templates/Uwp/Features/DeepLinking.MVVMLightVB/Strings/en-us/Resources_postaction.resw rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw index 18ceb96472..44b5757a7d 100644 --- a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Strings/en-us/Resources_postaction.resw +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Strings/en-us/Resources_postaction.resw @@ -6,7 +6,7 @@ - Scheme Activation Sample + SchemeActivationSample Page Title for URI Scheme Example diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..dbc37d6cda --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,17 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'{[{ + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + ViewModel.Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_BlankVB/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/.template.config/template.json new file mode 100644 index 0000000000..1147496209 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.DeepLinking.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs similarity index 92% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs index 3e43c2ccfe..20f2b01356 100644 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Activation/SchemeActivationHandler_postaction.cs @@ -26,7 +26,7 @@ protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs arg else if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page - NavigationService.Navigate(typeof(ViewModels.PivotViewModel).FullName); + NavigationService.Navigate(typeof(ViewModels.Param_HomeNameViewModel).FullName); } await Task.CompletedTask; diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..464671af06 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var parameters = e.Parameter as Dictionary; + if (parameters != null) + { + ViewModel.Initialize(parameters); + } + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..b1d9ccc97c --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/.template.config/template.json new file mode 100644 index 0000000000..6f1bb47051 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.DeepLinking.SplitView.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight.VB & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb similarity index 85% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb rename to templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb index 38f879804d..a63e3bf380 100644 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Activation/SchemeActivationHandler_postaction.vb @@ -1,5 +1,5 @@ -Namespace Activation - Friend Class SchemeActivationHandler +Namespace Activation + Friend Class SchemeActivationHandler Inherits ActivationHandler(Of ProtocolActivatedEventArgs) '{[{ @@ -16,7 +16,7 @@ If data.IsValid Then NavigationService.Navigate(data.ViewModelName, data.Parameters) ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then - NavigationService.Navigate(GetType(ViewModels.PivotViewModel).FullName) + NavigationService.Navigate(GetType(ViewModels.Param_HomeNameViewModel).FullName) End If Await Task.CompletedTask End Function diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..78dae72fbf --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,17 @@ +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'{[{ + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If e.Parameter IsNot Nothing Then + Dim parameters = TryCast(e.Parameter, Dictionary(Of String, String)) + ViewModel.Initialize(parameters) + End If + End Sub +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..b1d9ccc97c --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_SplitViewVB/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/.template.config/template.json new file mode 100644 index 0000000000..46f7017a3c --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.DeepLinking.TabbedPivot", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight & $projectType == TabbedPivot" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs new file mode 100644 index 0000000000..eeec36f636 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Activation/SchemeActivationHandler_postaction.cs @@ -0,0 +1,47 @@ +//{[{ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Views; +//}]} +namespace Param_ItemNamespace.Activation +{ + internal class SchemeActivationHandler : ActivationHandler + { +//{[{ + private NavigationServiceEx NavigationService + { + get + { + return CommonServiceLocator.ServiceLocator.Current.GetInstance(); + } + } + + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + protected override async Task HandleInternalAsync(ProtocolActivatedEventArgs args) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(args.Uri); + if (data.IsValid) + { + var frame = Window.Current.Content as Frame; + if (frame.Content is PivotPage pivotPage) + { + await pivotPage.InitializeFromSchemeActivationAsync(data); + } + else + { + NavigationService.Navigate(typeof(ViewModels.PivotViewModel).FullName, data); + } + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + NavigationService.Navigate(typeof(ViewModels.PivotViewModel).FullName); + } + + await Task.CompletedTask; + } + +//}]} + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs new file mode 100644 index 0000000000..7bfb70195b --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs @@ -0,0 +1,35 @@ +//{[{ +using System.Linq; +using Param_ItemNamespace.Activation; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class PivotPage : Page + { + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); +//{[{ + if (e.Parameter is SchemeActivationData data) + { + await InitializeFromSchemeActivationAsync(data); + } + +//}]} + } + +//{[{ + public async Task InitializeFromSchemeActivationAsync(SchemeActivationData schemeActivationData) + { + var selected = pivot.Items.Cast() + .FirstOrDefault(i => i.IsOfViewModelName(schemeActivationData.ViewModelName)); + + var page = selected?.GetPage(); + + pivot.SelectedItem = selected; + await page?.OnPivotActivatedAsync(schemeActivationData.Parameters); + } +//}]} + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs new file mode 100644 index 0000000000..87eebb9268 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_postaction.xaml.cs @@ -0,0 +1,19 @@ +//{[{ +using System.Threading.Tasks; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public SchemeActivationSamplePage() + { + InitializeComponent(); + } +//{[{ + + public async Task OnPivotActivatedAsync(Dictionary parameters) + { + ViewModel.Initialize(parameters); + await Task.CompletedTask; + } +//}]} +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs new file mode 100644 index 0000000000..11de633589 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivot/Views/SchemeActivationSamplePage_searchreplace.xaml.cs @@ -0,0 +1,3 @@ +public sealed partial class SchemeActivationSamplePage : Page +^^^-searchabove-replacebelow-vvv +public sealed partial class SchemeActivationSamplePage : Page, IPivotActivationPage diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json new file mode 100644 index 0000000000..4db3d7e41c --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.DeepLinking.TabbedPivot.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.MVVMLight.VB & $projectType == TabbedPivot" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb new file mode 100644 index 0000000000..086a7b9d0b --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Activation/SchemeActivationHandler_postaction.vb @@ -0,0 +1,34 @@ +'{[{ +Imports Param_ItemNamespace.Views +'}]} +Namespace Activation + Friend Class SchemeActivationHandler + Inherits ActivationHandler(Of ProtocolActivatedEventArgs) + '{[{ + + Private ReadOnly Property NavigationService As NavigationServiceEx + Get + Return CommonServiceLocator.ServiceLocator.Current.GetInstance(Of NavigationServiceEx)() + End Get + End Property + + ' By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + Protected Overrides Async Function HandleInternalAsync(args As ProtocolActivatedEventArgs) As Task + ' Create data from activation Uri in ProtocolActivatedEventArgs + Dim data = New SchemeActivationData(args.Uri) + If data.IsValid Then + Dim frame = TryCast(Window.Current.Content, Frame) + Dim pivotPage = TryCast(frame.Content, PivotPage) + If pivotPage IsNot Nothing Then + Await pivotPage.InitializeFromSchemeActivationAsync(data) + Else + NavigationService.Navigate(GetType(ViewModels.PivotViewModel).FullName, data) + End If + ElseIf args.PreviousExecutionState <> ApplicationExecutionState.Running Then + NavigationService.Navigate(GetType(ViewModels.PivotViewModel).FullName) + End If + Await Task.CompletedTask + End Function + '}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb new file mode 100644 index 0000000000..c1ab92b47a --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/PivotPage_postaction.xaml.vb @@ -0,0 +1,29 @@ +'{[{ +Imports System.Linq +Imports Param_ItemNamespace.Activation +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class PivotPage + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) +'{[{ + Dim data = TryCast(e.Parameter, SchemeActivationData) + If data IsNot Nothing + Await InitializeFromSchemeActivationAsync(data) + End If + +'}]} + Await Task.CompletedTask + End Sub + +'{[{ + Public Async Function InitializeFromSchemeActivationAsync(schemeActivationData As SchemeActivationData) As Task + Dim selected = pivot.Items.Cast(Of PivotItem)().FirstOrDefault(Function(i) i.IsOfViewModelName(schemeActivationData.ViewModelName)) + Dim page = selected?.GetPage(Of IPivotActivationPage)() + pivot.SelectedItem = selected + Await page?.OnPivotActivatedAsync(schemeActivationData.Parameters) + End Function +'}]} + End Class +End Namespace diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb new file mode 100644 index 0000000000..c60c455381 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_TabbedPivotVB/Views/SchemeActivationSamplePage_postaction.xaml.vb @@ -0,0 +1,21 @@ +'{[{ +Imports System.Threading.Tasks +Imports Param_ItemNamespace.Helpers +'}]} +Namespace Views + Public NotInheritable Partial Class SchemeActivationSamplePage + Inherits Page +'{[{ + Implements IPivotActivationPage +'}]} + + Public ReadOnly Property ViewModel As New SchemeActivationSampleViewModel +'{[{ + + Public Async Function OnPivotActivatedAsync(parameters As Dictionary(Of String, String)) As Task Implements IPivotActivationPage.OnPivotActivatedAsync + ViewModel.Initialize(parameters) + Await Task.CompletedTask + End Function +'}]} + End Class +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/.template.config/template.json new file mode 100644 index 0000000000..00f1616a32 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/.template.config/template.json @@ -0,0 +1,38 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "MVVMLight.Page.TabbedPivot.AddBehavior", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$projectType == TabbedPivot & $framework == MVVMLight & wts.type == page & identity == wts.Page.Camera|wts.Page.MediaPlayer" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Behaviors\\PivotBehavior.cs" + }, + { + "path": ".\\Helpers\\IPivotPage.cs" + }, + { + "path": ".\\Helpers\\PivotItemExtensions.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs new file mode 100644 index 0000000000..6cf88b5af9 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs @@ -0,0 +1,41 @@ +using System.Linq; +using Microsoft.Xaml.Interactivity; +using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Helpers; + +namespace Param_ItemNamespace.Behaviors +{ + public class PivotBehavior : Behavior + { + protected override void OnAttached() + { + base.OnAttached(); + AssociatedObject.SelectionChanged += OnSelectionChanged; + } + + protected override void OnDetaching() + { + base.OnDetaching(); + AssociatedObject.SelectionChanged -= OnSelectionChanged; + } + + private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + var removedItem = e.RemovedItems.Cast() + .Select(i => i.GetPage()).FirstOrDefault(); + + var addedItem = e.AddedItems.Cast() + .Select(i => i.GetPage()).FirstOrDefault(); + + if (removedItem != null) + { + await removedItem.OnPivotUnselectedAsync(); + } + + if (addedItem != null) + { + await addedItem?.OnPivotSelectedAsync(); + } + } + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/IPivotPage.cs b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/IPivotPage.cs new file mode 100644 index 0000000000..5342b842c3 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/IPivotPage.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; + +namespace Param_ItemNamespace.Helpers +{ + public interface IPivotPage + { + Task OnPivotSelectedAsync(); + + Task OnPivotUnselectedAsync(); + } +} diff --git a/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..6332b3dd64 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs @@ -0,0 +1,37 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is T element) + { + return element; + } + } + + return default(T); + } + + public static bool IsOfViewModelName(this PivotItem pivotItem, string viewModelName) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is Page page) + { + if (page.DataContext.GetType().FullName == viewModelName) + { + return true; + } + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml new file mode 100644 index 0000000000..31209f12e2 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml @@ -0,0 +1,21 @@ + + xmlns:behaviors="using:Param_ItemNamespace.Behaviors" + xmlns:i="using:Microsoft.Xaml.Interactivity" + + xmlns:model="using:Param_ItemNamespace.Models" + xmlns:views="using:Param_ItemNamespace.Views" + mc:Ignorable="d"> + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/.template.config/template.json index 365549b211..e6a8c0f51c 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/.template.config/template.json @@ -15,15 +15,18 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ - { - "path": ".\\ViewModels\\PivotViewModel.cs" - }, - { - "path": ".\\Views\\PivotPage.xaml" - }, - { - "path": ".\\Views\\PivotPage.xaml.cs" - } + { + "path": ".\\Helpers\\PivotItemExtensions.cs" + }, + { + "path": ".\\ViewModels\\PivotViewModel.cs" + }, + { + "path": ".\\Views\\PivotPage.xaml" + }, + { + "path": ".\\Views\\PivotPage.xaml.cs" + } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..9414f19721 --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Helpers/PivotItemExtensions.cs @@ -0,0 +1,37 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace wts.ItemName.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is T element) + { + return element; + } + } + + return default(T); + } + + public static bool IsOfViewModelName(this PivotItem pivotItem, string viewModelName) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is Page page) + { + if (page.DataContext.GetType().FullName == viewModelName) + { + return true; + } + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml index 54864631cc..9753e3df70 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml @@ -13,7 +13,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml.cs index cd510f23ef..14874462d6 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml.cs +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -1,7 +1,8 @@ using System; -using wts.ItemName.ViewModels; +using System.Threading.Tasks; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using wts.ItemName.ViewModels; namespace wts.ItemName.Views { @@ -20,5 +21,11 @@ public PivotPage() NavigationCacheMode = NavigationCacheMode.Required; InitializeComponent(); } + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await Task.CompletedTask; + } } } diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/.template.config/template.json index dedccb89e7..71aaa728b4 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/.template.config/template.json +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/.template.config/template.json @@ -16,15 +16,18 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ - { - "path": ".\\ViewModels\\PivotViewModel.vb" - }, - { - "path": ".\\Views\\PivotPage.xaml" - }, - { - "path": ".\\Views\\PivotPage.xaml.vb" - } + { + "path": ".\\Helpers\\PivotItemExtensions.vb" + }, + { + "path": ".\\ViewModels\\PivotViewModel.vb" + }, + { + "path": ".\\Views\\PivotPage.xaml" + }, + { + "path": ".\\Views\\PivotPage.xaml.vb" + } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Helpers/PivotItemExtensions.vb b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Helpers/PivotItemExtensions.vb new file mode 100644 index 0000000000..8e7130edce --- /dev/null +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Helpers/PivotItemExtensions.vb @@ -0,0 +1,31 @@ +Namespace Helpers + Friend Module PivotItemExtensions + + Function GetPage(Of T As Class)(pivotItem As PivotItem) As T + Dim frame = TryCast(pivotItem.Content, Frame) + If frame IsNot Nothing Then + Dim element = TryCast(frame.Content, T) + If element IsNot Nothing Then + Return element + End If + End If + + Return Nothing + End Function + + + Function IsOfViewModelName(pivotItem As PivotItem, viewModelName As String) As Boolean + Dim frame = TryCast(pivotItem.Content, Frame) + If frame IsNot Nothing Then + Dim page = TryCast(frame.Content, Page) + If page IsNot Nothing Then + If page.DataContext.GetType().FullName = viewModelName Then + Return True + End If + End If + End If + + Return False + End Function + End Module +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml index c3ca7a19f6..ab042938f3 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml @@ -13,7 +13,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml.vb b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml.vb index 18f6dcd41f..70109a76a7 100644 --- a/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml.vb +++ b/templates/Uwp/_composition/MVVMLight/Project.TabbedPivotVB/Views/PivotPage.xaml.vb @@ -17,5 +17,10 @@ Namespace Views ' https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh771188.aspx NavigationCacheMode = NavigationCacheMode.Required End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + Await Task.CompletedTask + End Sub End Class End Namespace diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/.template.config/template.json b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/.template.config/template.json new file mode 100644 index 0000000000..2c719bf67b --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Prism.DeepLinking.Blank", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.Prism & $projectType == Blank" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/Features/DeepLinking.Prism/App_postaction.xaml.cs b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/App_postaction.xaml.cs similarity index 100% rename from templates/Uwp/Features/DeepLinking.Prism/App_postaction.xaml.cs rename to templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/App_postaction.xaml.cs diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..aaa1280d40 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Page Title for URI Scheme Example + + + diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml new file mode 100644 index 0000000000..c33b5a72db --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_postaction.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + Grid.Row="0" + + + Grid.Row="1" + + Margin="{StaticResource SmallAllMargin}" /> + + \ No newline at end of file diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml new file mode 100644 index 0000000000..b67a01aa97 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_Blank/Views/SchemeActivationSamplePage_searchreplace.xaml @@ -0,0 +1,3 @@ + +^^^-searchabove-replacebelow-vvv + diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/.template.config/template.json b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/.template.config/template.json new file mode 100644 index 0000000000..aaae1e9784 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Prism.DeepLinking.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.Prism & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/App_postaction.xaml.cs b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/App_postaction.xaml.cs new file mode 100644 index 0000000000..8b7f6ef0f4 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/App_postaction.xaml.cs @@ -0,0 +1,42 @@ +using Windows.UI.Xaml; +//^^ +//{[{ +using Windows.UI.Xaml.Controls; +using Prism.Windows.Navigation; +using Param_RootNamespace.Activation; +using Param_RootNamespace.Views; +//}]} + +namespace Param_RootNamespace +{ + public sealed partial class App : PrismUnityApplication + { + public App() + { + InitializeComponent(); + } + + protected override async Task OnActivateApplicationAsync(IActivatedEventArgs args) + { +//{[{ + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + if (args.Kind == ActivationKind.Protocol && args is ProtocolActivatedEventArgs protocolArgs && protocolArgs.Uri != null) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(protocolArgs.Uri); + if (data.IsValid) + { + await LaunchApplicationAsync(data.PageToken, data.Parameters); + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + await OnLaunchApplicationAsync(args as LaunchActivatedEventArgs); + } + } +//}]} + + await Task.CompletedTask; + } + } +} diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..a6ec6ad25a --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + SchemeActivationSample + Navigation view item name for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml new file mode 100644 index 0000000000..aac2c3093e --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_SplitView/Views/ShellPage_postaction.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/.template.config/template.json new file mode 100644 index 0000000000..c4e2e0af57 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Prism.DeepLinking.TabbedPivot", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "identity == wts.Feat.DeepLinking.Prism & $projectType == TabbedPivot" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/App_postaction.xaml.cs b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/App_postaction.xaml.cs new file mode 100644 index 0000000000..770100e05b --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/App_postaction.xaml.cs @@ -0,0 +1,50 @@ +using Windows.UI.Xaml; +//^^ +//{[{ +using Windows.UI.Xaml.Controls; +using Prism.Windows.Navigation; +using Param_RootNamespace.Activation; +using Param_RootNamespace.Views; +//}]} + +namespace Param_RootNamespace +{ + public sealed partial class App : PrismUnityApplication + { + public App() + { + InitializeComponent(); + } + + protected override async Task OnActivateApplicationAsync(IActivatedEventArgs args) + { +//{[{ + // By default, this handler expects URIs of the format 'wtsapp:sample?paramName1=paramValue1¶mName2=paramValue2' + if (args.Kind == ActivationKind.Protocol && args is ProtocolActivatedEventArgs protocolArgs && protocolArgs.Uri != null) + { + // Create data from activation Uri in ProtocolActivatedEventArgs + var data = new SchemeActivationData(protocolArgs.Uri); + if (data.IsValid) + { + var frame = Window.Current.Content as Frame; + if (frame.Content is PivotPage pivotPage) + { + pivotPage.InitializeFromSchemeActivation(data); + } + else + { + await LaunchApplicationAsync(PageTokens.PivotPage, data); + } + } + else if (args.PreviousExecutionState != ApplicationExecutionState.Running) + { + // If the app isn't running and not navigating to a specific page based on the URI, navigate to the home page + await OnLaunchApplicationAsync(args as LaunchActivatedEventArgs); + } + } +//}]} + + await Task.CompletedTask; + } + } +} diff --git a/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs new file mode 100644 index 0000000000..05117a7658 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Feature.DeepLinking_TabbedPivot/Views/PivotPage_postaction.xaml.cs @@ -0,0 +1,37 @@ +//{[{ +using System.Linq; +using Prism.Windows.Navigation; +using Param_ItemNamespace.Activation; +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.Views +{ + public sealed partial class PivotPage : Page + { + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); +//{[{ + if (e.Parameter is SchemeActivationData data) + { + InitializeFromSchemeActivation(data); + } + +//}]} + } + +//{[{ + public void InitializeFromSchemeActivation(SchemeActivationData schemeActivationData) + { + var selected = pivot.Items.Cast() + .FirstOrDefault(i => i.IsOfPageType(schemeActivationData.PageToken)); + pivot.SelectedItem = selected; + + var viewModel = selected?.GetPage(); + var args = new NavigatedToEventArgs(); + args.Parameter = schemeActivationData.Parameters; + viewModel.OnNavigatedTo(args, null); + } +//}]} + } +} diff --git a/templates/Uwp/_composition/Prism/Feature.MultiView/App.xaml_postaction.cs b/templates/Uwp/_composition/Prism/Feature.MultiView/App.xaml_postaction.cs index 6a0afd4232..7bd27c3646 100644 --- a/templates/Uwp/_composition/Prism/Feature.MultiView/App.xaml_postaction.cs +++ b/templates/Uwp/_composition/Prism/Feature.MultiView/App.xaml_postaction.cs @@ -5,6 +5,11 @@ protected override async Task OnInitializeAsync(IActivatedEventArgs args) { //{[{ - WindowManagerService.Current.Initialize(); + await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( + Windows.UI.Core.CoreDispatcherPriority.Normal, + () => + { + WindowManagerService.Current.Initialize(); + }); //}]} } diff --git a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/.template.config/template.json b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/.template.config/template.json index 20d125c7c4..bd133af852 100644 --- a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/.template.config/template.json +++ b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/.template.config/template.json @@ -17,6 +17,9 @@ "PrimaryOutputs": [ { "path": ".\\Behaviors\\PivotNavigationBehavior.cs" + }, + { + "path": ".\\Helpers\\PivotItemExtensions.cs" } ], "symbols": { diff --git a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Behaviors/PivotNavigationBehavior.cs b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Behaviors/PivotNavigationBehavior.cs index 15c4b1b12f..4e908772e6 100644 --- a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Behaviors/PivotNavigationBehavior.cs +++ b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Behaviors/PivotNavigationBehavior.cs @@ -4,6 +4,7 @@ using System.Linq; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Helpers; namespace Param_ItemNamespace.Behaviors { @@ -24,29 +25,13 @@ protected override void OnDetaching() private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); removedItem?.OnNavigatingFrom(null, null, false); addedItem?.OnNavigatedTo(null, null); } - - private static INavigationAware GetPivotPage(PivotItem pivotItem) - { - if (pivotItem.Content is Frame frame) - { - if (frame.Content is FrameworkElement frameworkElement) - { - if (frameworkElement.DataContext is INavigationAware navigationAware) - { - return navigationAware; - } - } - } - - return null; - } } } diff --git a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..2810ac03e5 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs @@ -0,0 +1,38 @@ +using System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is FrameworkElement frameworkElement) + { + if (frameworkElement.DataContext is T element) + { + return element; + } + } + } + + return default(T); + } + + public static bool IsOfPageType(this PivotItem pivotItem, string pageToken) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content.GetType().Name == $"{pageToken}Page") + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml index c5cc253c6b..a2a38fe4ae 100644 --- a/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml +++ b/templates/Uwp/_composition/Prism/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml @@ -2,7 +2,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/Prism/Project.TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/Prism/Project.TabbedPivot/.template.config/template.json index 229159cba6..9574982a3d 100644 --- a/templates/Uwp/_composition/Prism/Project.TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/Prism/Project.TabbedPivot/.template.config/template.json @@ -15,18 +15,21 @@ "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ - { - "path": ".\\ViewModels\\PivotViewModel.cs" - }, - { - "path": ".\\Views\\PivotPage.xaml" - }, - { - "path": ".\\Views\\PivotPage.xaml.cs" - }, - { - "path": ".\\Behaviors\\PivotNavigationBehavior.cs" - } + { + "path": ".\\Helpers\\PivotItemExtensions.cs" + }, + { + "path": ".\\ViewModels\\PivotViewModel.cs" + }, + { + "path": ".\\Views\\PivotPage.xaml" + }, + { + "path": ".\\Views\\PivotPage.xaml.cs" + }, + { + "path": ".\\Behaviors\\PivotNavigationBehavior.cs" + } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Behaviors/PivotNavigationBehavior.cs b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Behaviors/PivotNavigationBehavior.cs index 418d71b425..4e908772e6 100644 --- a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Behaviors/PivotNavigationBehavior.cs +++ b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Behaviors/PivotNavigationBehavior.cs @@ -4,8 +4,9 @@ using System.Linq; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Helpers; -namespace wts.ItemName.Behaviors +namespace Param_ItemNamespace.Behaviors { public class PivotNavigationBehavior : Behavior { @@ -24,29 +25,13 @@ protected override void OnDetaching() private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); removedItem?.OnNavigatingFrom(null, null, false); addedItem?.OnNavigatedTo(null, null); } - - private static INavigationAware GetPivotPage(PivotItem pivotItem) - { - if (pivotItem.Content is Frame frame) - { - if (frame.Content is FrameworkElement frameworkElement) - { - if (frameworkElement.DataContext is INavigationAware navigationAware) - { - return navigationAware; - } - } - } - - return null; - } } } diff --git a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..8ef9208691 --- /dev/null +++ b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Helpers/PivotItemExtensions.cs @@ -0,0 +1,38 @@ +using System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace wts.ItemName.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is FrameworkElement frameworkElement) + { + if (frameworkElement.DataContext is T element) + { + return element; + } + } + } + + return default(T); + } + + public static bool IsOfPageType(this PivotItem pivotItem, string pageToken) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content.GetType().Name == $"{pageToken}Page") + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml index 2b4e0c7a61..40b34c41f0 100644 --- a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml +++ b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml @@ -13,7 +13,7 @@ mc:Ignorable="d"> - + diff --git a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml.cs index e74cb72ce0..c0a491904c 100644 --- a/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml.cs +++ b/templates/Uwp/_composition/Prism/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using wts.ItemName.ViewModels; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; @@ -17,5 +18,11 @@ public PivotPage() NavigationCacheMode = NavigationCacheMode.Required; InitializeComponent(); } + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await Task.CompletedTask; + } } } diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandler/.template.config/template.json similarity index 86% rename from templates/Uwp/_composition/_shared/Feature.DeepLinking/.template.config/template.json rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandler/.template.config/template.json index f518221766..5859fd3061 100644 --- a/templates/Uwp/_composition/_shared/Feature.DeepLinking/.template.config/template.json +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandler/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "Feature.DeepLinking", + "name": "Feature.DeepLinking.AddActivationHandler", "tags": { "language": "C#", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & identity == wts.Feat.DeepLinking|wts.Feat.DeepLinking.MVVMLight" + "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & groupidentity == wts.Feat.DeepLinking" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking/Services/ActivationService_postaction.cs b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandler/Services/ActivationService_postaction.cs similarity index 100% rename from templates/Uwp/_composition/_shared/Feature.DeepLinking/Services/ActivationService_postaction.cs rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandler/Services/ActivationService_postaction.cs diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinkingVB/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandlerVB/.template.config/template.json similarity index 85% rename from templates/Uwp/_composition/_shared/Feature.DeepLinkingVB/.template.config/template.json rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandlerVB/.template.config/template.json index 36330b0c81..c3639c44ab 100644 --- a/templates/Uwp/_composition/_shared/Feature.DeepLinkingVB/.template.config/template.json +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandlerVB/.template.config/template.json @@ -3,14 +3,14 @@ "classifications": [ "Universal" ], - "name": "Feature.DeepLinking.VB", + "name": "Feature.DeepLinking.AddActivationHandler.VB", "tags": { "language": "VisualBasic", "type": "item", "wts.type": "composition", "wts.platform": "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & identity == wts.Feat.DeepLinking.VB|wts.Feat.DeepLinking.MVVMLight.VB" + "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & groupidentity == wts.Feat.DeepLinking.VB" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinkingVB/Services/ActivationService_postaction.vb b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandlerVB/Services/ActivationService_postaction.vb similarity index 100% rename from templates/Uwp/_composition/_shared/Feature.DeepLinkingVB/Services/ActivationService_postaction.vb rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddActivationHandlerVB/Services/ActivationService_postaction.vb diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/.template.config/template.json new file mode 100644 index 0000000000..f38414fec0 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/.template.config/template.json @@ -0,0 +1,36 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Feature.DeepLinking.AddLogoTextsAndAppxManifest", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "groupidentity == wts.Feat.DeepLinking" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Assets\\Logo.png" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/Features/DeepLinking.MVVMLight/Assets/Logo.png b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Assets/Logo.png similarity index 100% rename from templates/Uwp/Features/DeepLinking.MVVMLight/Assets/Logo.png rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Assets/Logo.png diff --git a/templates/Uwp/Features/DeepLinking.MVVMLight/Package_postaction.appxmanifest b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Package_postaction.appxmanifest similarity index 100% rename from templates/Uwp/Features/DeepLinking.MVVMLight/Package_postaction.appxmanifest rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Package_postaction.appxmanifest diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..801d2bd418 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifest/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + This is a sample page that will show activation parameters if the app is activated from Deep Linking. + Description text for SchemeActivationSamplePage + + + diff --git a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/.template.config/template.json similarity index 75% rename from templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/.template.config/template.json index ba10d07410..1e4c50b3b4 100644 --- a/templates/Uwp/_composition/MVVMLight/Feature.DeepLinking_Activation_Blank_SplitViewVB/.template.config/template.json +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/.template.config/template.json @@ -3,18 +3,21 @@ "classifications": [ "Universal" ], - "name": "wts.Feat.DeepLinking.MVVMLight.Activavtion.BlankOrSplitView.VB", + "name": "Feature.DeepLinking.AddLogoTextsAndAppxManifest.VB", "tags": { "language": "VisualBasic", "type": "item", "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMLight & identity == wts.Feat.DeepLinking.MVVMLight.VB & $projectType == Blank|SplitView" + "wts.compositionFilter": "groupidentity == wts.Feat.DeepLinking.VB" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, "PrimaryOutputs": [ + { + "path": ".\\Assets\\Logo.png" + } ], "symbols": { "wts.rootNamespace": { diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Assets/Logo.png b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Assets/Logo.png similarity index 100% rename from templates/Uwp/Features/DeepLinking.MVVMLightVB/Assets/Logo.png rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Assets/Logo.png diff --git a/templates/Uwp/Features/DeepLinking.MVVMLightVB/Package_postaction.appxmanifest b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Package_postaction.appxmanifest similarity index 100% rename from templates/Uwp/Features/DeepLinking.MVVMLightVB/Package_postaction.appxmanifest rename to templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Package_postaction.appxmanifest diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..801d2bd418 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.AddLogoTextsAndAppxManifestVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + This is a sample page that will show activation parameters if the app is activated from Deep Linking. + Description text for SchemeActivationSamplePage + + + diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/.template.config/template.json new file mode 100644 index 0000000000..4074924e7e --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/.template.config/template.json @@ -0,0 +1,36 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Feature.DeepLinking.TabbedPivot", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "groupidentity == wts.Feat.DeepLinking & $projectType == TabbedPivot & $framework == CodeBehind|MVVMBasic|MVVMLight|Prism" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Helpers\\IPivotActivationPage.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Helpers/IPivotActivationPage.cs b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Helpers/IPivotActivationPage.cs new file mode 100644 index 0000000000..5593191c0b --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Helpers/IPivotActivationPage.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Param_ItemNamespace.Helpers +{ + public interface IPivotActivationPage + { + Task OnPivotActivatedAsync(Dictionary parameters); + } +} diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..eb676c9384 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,9 @@ + + + + + SchemeActivationSample + Pivot item header for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Views/PivotPage_postaction.xaml new file mode 100644 index 0000000000..65c72a62a9 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivot/Views/PivotPage_postaction.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/.template.config/template.json b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/.template.config/template.json new file mode 100644 index 0000000000..9793504a00 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/.template.config/template.json @@ -0,0 +1,36 @@ +{ + "author": "Microsoft Community", + "classifications": [ + "Universal" + ], + "name": "Feature.DeepLinking.TabbedPivot.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "groupidentity == wts.Feat.DeepLinking.VB & $projectType == TabbedPivot" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Helpers\\IPivotActivationPage.vb" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Helpers/IPivotActivationPage.vb b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Helpers/IPivotActivationPage.vb new file mode 100644 index 0000000000..d2f9cbbf38 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Helpers/IPivotActivationPage.vb @@ -0,0 +1,8 @@ +Imports System.Collections.Generic +Imports System.Threading.Tasks + +Namespace Helpers + Interface IPivotActivationPage + Function OnPivotActivatedAsync(parameters As Dictionary(Of String, String)) As Task + End Interface +End Namespace diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Strings/en-us/Resources_postaction.resw b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Strings/en-us/Resources_postaction.resw new file mode 100644 index 0000000000..eb676c9384 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,9 @@ + + + + + SchemeActivationSample + Pivot item header for SchemeActivationSample + + + diff --git a/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Views/PivotPage_postaction.xaml new file mode 100644 index 0000000000..65c72a62a9 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Feature.DeepLinking.TabbedPivotVB/Views/PivotPage_postaction.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/.template.config/template.json b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/.template.config/template.json index 30885e6c79..a943bdb0c8 100644 --- a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/.template.config/template.json +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/.template.config/template.json @@ -10,7 +10,7 @@ "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$projectType == TabbedPivot & $framework == CodeBehind|MVVMBasic|MVVMLight & wts.type == page & identity == wts.Page.Camera|wts.Page.Camera.CodeBehind|wts.Page.MediaPlayer|wts.Page.MediaPlayer.CodeBehind" + "wts.compositionFilter": "$projectType == TabbedPivot & $framework == CodeBehind|MVVMBasic & wts.type == page & identity == wts.Page.Camera|wts.Page.Camera.CodeBehind|wts.Page.MediaPlayer|wts.Page.MediaPlayer.CodeBehind" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, @@ -20,6 +20,9 @@ }, { "path": ".\\Helpers\\IPivotPage.cs" + }, + { + "path": ".\\Helpers\\PivotItemExtensions.cs" } ], "symbols": { diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs index abedb18b9f..6cf88b5af9 100644 --- a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Behaviors/PivotBehavior.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using Microsoft.Xaml.Interactivity; using Windows.UI.Xaml.Controls; using Param_ItemNamespace.Helpers; @@ -23,10 +22,10 @@ protected override void OnDetaching() private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); if (removedItem != null) { @@ -38,18 +37,5 @@ private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e await addedItem?.OnPivotSelectedAsync(); } } - - private static IPivotPage GetPivotPage(PivotItem pivotItem) - { - if (pivotItem.Content is Frame frame) - { - if (frame.Content is IPivotPage pivotPage) - { - return pivotPage; - } - } - - return null; - } } } diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..13c8f5b538 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Helpers/PivotItemExtensions.cs @@ -0,0 +1,34 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is T element) + { + return element; + } + } + + return default(T); + } + + public static bool IsOfPageType(this PivotItem pivotItem, Type pageType) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content.GetType() == pageType) + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml index 0380944df8..31209f12e2 100644 --- a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehavior/Views/PivotPage_postaction.xaml @@ -10,7 +10,7 @@ - + diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Behaviors/PivotBehavior.vb b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Behaviors/PivotBehavior.vb index e1834a8002..c08e1ecb2d 100644 --- a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Behaviors/PivotBehavior.vb +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Behaviors/PivotBehavior.vb @@ -17,8 +17,8 @@ Namespace Behaviors End Sub Private Async Sub OnSelectionChanged(sender As Object, e As SelectionChangedEventArgs) - Dim removedItem = e.RemovedItems.Cast(Of PivotItem).Select(Function(pi) GetPivotPage(pi)).FirstOrDefault() - Dim addedItem = e.AddedItems.Cast(Of PivotItem).Select(Function(pi) GetPivotPage(pi)).FirstOrDefault() + Dim removedItem = e.RemovedItems.Cast(Of PivotItem).Select(Function(pi) pi.GetPage(Of IPivotPage)).FirstOrDefault() + Dim addedItem = e.AddedItems.Cast(Of PivotItem).Select(Function(pi) pi.GetPage(Of IPivotPage)).FirstOrDefault() If removedItem IsNot Nothing Then Await removedItem.OnPivotUnselectedAsync() End If @@ -27,14 +27,5 @@ Namespace Behaviors Await addedItem.OnPivotSelectedAsync() End If End Sub - - Private Function GetPivotPage(pivotItem As PivotItem) As IPivotPage - Dim frame = TryCast(pivotItem.Content, Frame) - If frame IsNot Nothing Then - Return TryCast(frame.Content, IPivotPage) - Else - Return Nothing - End If - End Function End Class End Namespace diff --git a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Views/PivotPage_postaction.xaml index 0380944df8..31209f12e2 100644 --- a/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Views/PivotPage_postaction.xaml +++ b/templates/Uwp/_composition/_shared/Page.TabbedPivot.AddBehaviorVB/Views/PivotPage_postaction.xaml @@ -10,7 +10,7 @@ - + diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/.template.config/template.json b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/.template.config/template.json new file mode 100644 index 0000000000..5a166f55c7 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/.template.config/template.json @@ -0,0 +1,32 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "Project.TabbedPivot.AddPivotItemExtensions", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$projectType == TabbedPivot & wts.type == project & $framework == CodeBehind|MVVMBasic" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Helpers\\PivotItemExtensions.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/Helpers/PivotItemExtensions.cs b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/Helpers/PivotItemExtensions.cs new file mode 100644 index 0000000000..75676e912d --- /dev/null +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensions/Helpers/PivotItemExtensions.cs @@ -0,0 +1,34 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace wts.ItemName.Helpers +{ + public static class PivotItemExtensions + { + public static T GetPage(this PivotItem pivotItem) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content is T element) + { + return element; + } + } + + return default(T); + } + + public static bool IsOfPageType(this PivotItem pivotItem, Type pageType) + { + if (pivotItem.Content is Frame frame) + { + if (frame.Content.GetType() == pageType) + { + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/.template.config/template.json b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/.template.config/template.json new file mode 100644 index 0000000000..2ef06e1789 --- /dev/null +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/.template.config/template.json @@ -0,0 +1,32 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "Project.TabbedPivot.AddPivotItemExtensions.VB", + "tags": { + "language": "VisualBasic", + "type": "item", + "wts.type": "composition", + "wts.platform" : "Uwp", + "wts.version": "1.0.0", + "wts.compositionFilter": "$projectType == TabbedPivot & wts.type == project & $framework == CodeBehind|MVVMBasic" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Helpers\\PivotItemExtensions.vb" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/Helpers/PivotItemExtensions.vb b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/Helpers/PivotItemExtensions.vb new file mode 100644 index 0000000000..e7934a357f --- /dev/null +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddPivotItemExtensionsVB/Helpers/PivotItemExtensions.vb @@ -0,0 +1,31 @@ +Namespace Helpers + Friend Module PivotItemExtensions + + Function GetPage(Of T As Class)(pivotItem As PivotItem) As T + Dim frame = TryCast(pivotItem.Content, Frame) + If frame IsNot Nothing Then + Dim element = TryCast(frame.Content, T) + If element IsNot Nothing Then + Return element + End If + End If + + Return Nothing + End Function + + + Function IsOfPageType(pivotItem As PivotItem, pageType As Type) As Boolean + Dim frame = TryCast(pivotItem.Content, Frame) + If frame IsNot Nothing Then + Dim page = TryCast(frame.Content, Page) + If page IsNot Nothing Then + If page.GetType() = pageType Then + Return True + End If + End If + End If + + Return False + End Function + End Module +End Namespace \ No newline at end of file diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/Views/PivotPage_postaction.xaml index 03f040ee06..6199a7b228 100644 --- a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/Views/PivotPage_postaction.xaml +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/Views/PivotPage_postaction.xaml @@ -1,4 +1,4 @@ - + diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItemsVB/Views/PivotPage_postaction.xaml b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItemsVB/Views/PivotPage_postaction.xaml index 03f040ee06..6199a7b228 100644 --- a/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItemsVB/Views/PivotPage_postaction.xaml +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItemsVB/Views/PivotPage_postaction.xaml @@ -1,4 +1,4 @@ - + diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot/.template.config/template.json b/templates/Uwp/_composition/_shared/Project.TabbedPivot/.template.config/template.json index 33499ec69c..d5c255489b 100644 --- a/templates/Uwp/_composition/_shared/Project.TabbedPivot/.template.config/template.json +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot/.template.config/template.json @@ -10,7 +10,7 @@ "wts.type": "composition", "wts.platform" : "Uwp", "wts.version": "1.0.0", - "wts.compositionFilter": "$projectType == TabbedPivot & wts.type == project & $framework == CodeBehind|MVVMBasic|MVVMLight" + "wts.compositionFilter": "$projectType == TabbedPivot & wts.type == project & $framework == CodeBehind|MVVMBasic|MVVMLight|Prism" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivot/Behaviors/PivotBehavior.cs b/templates/Uwp/_composition/_shared/Project.TabbedPivot/Behaviors/PivotBehavior.cs index 1abc62aebc..4eb6a3b2dd 100644 --- a/templates/Uwp/_composition/_shared/Project.TabbedPivot/Behaviors/PivotBehavior.cs +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivot/Behaviors/PivotBehavior.cs @@ -1,10 +1,10 @@ -using System; -using System.Linq; +using System.Linq; using Microsoft.Xaml.Interactivity; +using Param_ItemNamespace.Helpers; + using Windows.UI.Xaml.Controls; -using wts.ItemName.Helpers; -namespace wts.ItemName.Behaviors +namespace Param_ItemNamespace.Behaviors { public class PivotBehavior : Behavior { @@ -23,10 +23,10 @@ protected override void OnDetaching() private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var removedItem = e.RemovedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); var addedItem = e.AddedItems.Cast() - .Select(i => GetPivotPage(i)).FirstOrDefault(); + .Select(i => i.GetPage()).FirstOrDefault(); if (removedItem != null) { @@ -38,18 +38,5 @@ private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e await addedItem?.OnPivotSelectedAsync(); } } - - private static IPivotPage GetPivotPage(PivotItem pivotItem) - { - if (pivotItem.Content is Frame frame) - { - if (frame.Content is IPivotPage pivotPage) - { - return pivotPage; - } - } - - return null; - } } -} +} \ No newline at end of file diff --git a/templates/Uwp/_composition/_shared/Project.TabbedPivotVB/Behaviors/PivotBehavior.vb b/templates/Uwp/_composition/_shared/Project.TabbedPivotVB/Behaviors/PivotBehavior.vb index 54120b92e3..dfbe7e26c6 100644 --- a/templates/Uwp/_composition/_shared/Project.TabbedPivotVB/Behaviors/PivotBehavior.vb +++ b/templates/Uwp/_composition/_shared/Project.TabbedPivotVB/Behaviors/PivotBehavior.vb @@ -17,8 +17,8 @@ Namespace Behaviors End Sub Private Async Sub OnSelectionChanged(sender As Object, e As SelectionChangedEventArgs) - Dim removedItem = e.RemovedItems.Cast(Of PivotItem).Select(Function(pi) GetPivotPage(pi)).FirstOrDefault() - Dim addedItem = e.AddedItems.Cast(Of PivotItem).Select(Function(pi) GetPivotPage(pi)).FirstOrDefault() + Dim removedItem = e.RemovedItems.Cast(Of PivotItem).Select(Function(pi) pi.GetPage(Of IPivotPage)).FirstOrDefault() + Dim addedItem = e.AddedItems.Cast(Of PivotItem).Select(Function(pi) pi.GetPage(Of IPivotPage)).FirstOrDefault() If removedItem IsNot Nothing Then Await removedItem.OnPivotUnselectedAsync() End If @@ -27,14 +27,5 @@ Namespace Behaviors Await addedItem.OnPivotSelectedAsync() End If End Sub - - Private Function GetPivotPage(pivotItem As PivotItem) As IPivotPage - Dim frame = TryCast(pivotItem.Content, Frame) - If frame IsNot Nothing Then - Return TryCast(frame.Content, IPivotPage) - Else - Return Nothing - End If - End Function End Class End Namespace \ No newline at end of file