From 820daaf413f15f3dfa984c867418c4c5c05a8892 Mon Sep 17 00:00:00 2001 From: William Bradley Date: Tue, 6 Feb 2018 13:12:26 +1300 Subject: [PATCH] Replaced string Navigation Parameter with NavigationParameters class, which is based on a string Dictionary. This allows for more complex Navigation data. --- Core/Models/NavigationParameters.cs | 20 ++++++++ Core/Services/NavigationManager.cs | 8 +-- Core/Services/Navigator.cs | 51 +++++++++++-------- Platform/PlatformBindings-Platform.csproj | 4 +- .../Android/Resources/Resource.Designer.cs | 12 +++++ .../Services/AndroidActivityNavigator.cs | 40 +++++++++++---- .../Services/AndroidFragmentNavigator.cs | 9 ++-- .../Compat/AndroidCompatFragmentNavigator.cs | 9 ++-- .../Platforms/UWP/Services/UWPNavigator.cs | 22 ++++++-- .../Win32/Services/Win32Navigator.cs | 23 ++++++--- .../Services/TestAndroidNavigator.cs | 10 +++- .../Android/Test-Android/Views/TestViewer.cs | 4 +- .../Tests-Universal/TestGenerator/TestTask.cs | 12 ++++- .../UWP/Test-UWP/Services/TestUWPNavigator.cs | 10 +++- .../UWP/Test-UWP/Views/TestViewer.xaml.cs | 4 +- TestApps/WPF/Test-WPF/MainWindow.xaml | 2 +- .../WPF/Test-WPF/Services/TestWPFNavigator.cs | 12 +++-- .../WPF/Test-WPF/Views/TestViewer.xaml.cs | 4 +- version.json | 2 +- 19 files changed, 184 insertions(+), 74 deletions(-) create mode 100644 Core/Models/NavigationParameters.cs diff --git a/Core/Models/NavigationParameters.cs b/Core/Models/NavigationParameters.cs new file mode 100644 index 0000000..f06694b --- /dev/null +++ b/Core/Models/NavigationParameters.cs @@ -0,0 +1,20 @@ +// ****************************************************************** +// Copyright (c) William Bradley +// This code is licensed under the MIT License (MIT). +// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. +// ****************************************************************** + +using System.Collections.Generic; + +namespace PlatformBindings.Models +{ + public class NavigationParameters : Dictionary + { + } +} \ No newline at end of file diff --git a/Core/Services/NavigationManager.cs b/Core/Services/NavigationManager.cs index b01926d..4d28581 100644 --- a/Core/Services/NavigationManager.cs +++ b/Core/Services/NavigationManager.cs @@ -27,14 +27,14 @@ public void Navigate(object Page) Navigator.Navigate(Page); } - public void Navigate(object Page, string Parameter) + public void Navigate(object Page, NavigationParameters Parameters) { - Navigator.Navigate(Page, Parameter); + Navigator.Navigate(Page, Parameters); } - public void Navigate(object Page, string Parameter, bool ClearBackStack) + public void Navigate(object Page, NavigationParameters Parameters, bool ClearBackStack) { - Navigator.Navigate(Page, Parameter, ClearBackStack); + Navigator.Navigate(Page, Parameters, ClearBackStack); } public abstract void GoBack(); diff --git a/Core/Services/Navigator.cs b/Core/Services/Navigator.cs index c4361b8..65b8935 100644 --- a/Core/Services/Navigator.cs +++ b/Core/Services/Navigator.cs @@ -10,6 +10,8 @@ // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. // ****************************************************************** +using PlatformBindings.Models; + namespace PlatformBindings.Services { /// @@ -22,7 +24,10 @@ public abstract class Navigator /// /// Page to Navigate to. /// Navigation Handled - public abstract bool Navigate(object Page); + public bool Navigate(object Page) + { + return Navigate(Page, null); + } /// /// Navigates to the requested Page, supplying a Parameter. @@ -30,7 +35,10 @@ public abstract class Navigator /// Page to Navigate to. /// Parameter, can be serialised. /// Navigation Handled - public abstract bool Navigate(object Page, string Parameter); + public bool Navigate(object Page, NavigationParameters Parameters) + { + return Navigate(Page, Parameters, false); + } /// /// Navigates to the requested Page, supplying a Parameter. @@ -39,12 +47,15 @@ public abstract class Navigator /// Parameter, can be serialised. /// Clear the Navigation Back Stack? /// Navigation Handled - public abstract bool Navigate(object Page, string Parameter, bool ClearBackStack); + public virtual bool Navigate(object Page, NavigationParameters Parameters, bool ClearBackStack) + { + return false; + } /// /// Gets the Parameter from the Current Page's Navigation Event. /// - public abstract string Parameter { get; } + public abstract NavigationParameters Parameters { get; } } /// @@ -60,31 +71,27 @@ public abstract class Navigator : Navigator /// Parameter, can be serialised. /// Clear the Navigation Back Stack? /// Navigation Handled - public abstract bool Navigate(TPageIdentifier Page, string Parameter, bool ClearBackStack); + public abstract bool Navigate(TPageIdentifier Page, NavigationParameters Parameters, bool ClearBackStack); /// - /// Checks Casting + /// Navigates to the requested Page, supplying a Parameter. /// - /// - /// - public override bool Navigate(object Page) + /// Page to Navigate to. + /// Parameter, can be serialised. + /// Navigation Handled + public bool Navigate(TPageIdentifier Page, NavigationParameters Parameters) { - return Navigate(Page, null); + return Navigate(Page, Parameters, false); } /// - /// Checks casting for Valid Navigation. + /// Navigates to the requested Page, supplying a Parameter. /// - /// Page to Navigate to (Must derrive of Generic) - /// Page Parameter. + /// Page to Navigate to. /// Navigation Handled - public override bool Navigate(object Page, string Parameter) + public bool Navigate(TPageIdentifier Page) { - if (Page is TPageIdentifier generic) - { - return Navigate(generic, Parameter, false); - } - else return false; + return Navigate(Page, null); } /// @@ -94,13 +101,13 @@ public override bool Navigate(object Page, string Parameter) /// Page Parameter. /// Clear the Navigation Back Stack? /// Navigation Handled - public override bool Navigate(object Page, string Parameter, bool ClearBackStack) + public override bool Navigate(object Page, NavigationParameters Parameters, bool ClearBackStack) { if (Page is TPageIdentifier generic) { - return Navigate(generic, Parameter, ClearBackStack); + return Navigate(generic, Parameters, ClearBackStack); } - else return false; + else return base.Navigate(Page, Parameters, ClearBackStack); } } } \ No newline at end of file diff --git a/Platform/PlatformBindings-Platform.csproj b/Platform/PlatformBindings-Platform.csproj index 80cd6c9..bf315a4 100644 --- a/Platform/PlatformBindings-Platform.csproj +++ b/Platform/PlatformBindings-Platform.csproj @@ -32,7 +32,9 @@ Off True True - Platforms\Android\Resources\Resource.Designer.cs + diff --git a/Platform/Platforms/Android/Resources/Resource.Designer.cs b/Platform/Platforms/Android/Resources/Resource.Designer.cs index e69de29..9be4db2 100644 --- a/Platform/Platforms/Android/Resources/Resource.Designer.cs +++ b/Platform/Platforms/Android/Resources/Resource.Designer.cs @@ -0,0 +1,12 @@ +// ****************************************************************** +// Copyright (c) William Bradley +// This code is licensed under the MIT License (MIT). +// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. +// ****************************************************************** + diff --git a/Platform/Platforms/Android/Services/AndroidActivityNavigator.cs b/Platform/Platforms/Android/Services/AndroidActivityNavigator.cs index 08bced8..84d0a44 100644 --- a/Platform/Platforms/Android/Services/AndroidActivityNavigator.cs +++ b/Platform/Platforms/Android/Services/AndroidActivityNavigator.cs @@ -12,8 +12,10 @@ using Android.App; using Android.Content; +using Newtonsoft.Json; using PlatformBindings.Activities; using PlatformBindings.Common; +using PlatformBindings.Models; using System; namespace PlatformBindings.Services @@ -37,26 +39,34 @@ private void ActivityHandler_ActivityChanged(object sender, EventArgs e) } } - protected virtual bool InternalNavigate(Type Type, string Parameter) + protected virtual bool InternalNavigate(Type Type) { - return InternalNavigate(Type, Parameter, true); + return InternalNavigate(Type, null, true); } - protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBack) + protected virtual bool InternalNavigate(Type Type, NavigationParameters Parameters) { - return InternalNavigate(Type, Parameter, ShowBack, false); + return InternalNavigate(Type, Parameters, true); } - protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBack, bool ClearBackStack) + protected virtual bool InternalNavigate(Type Type, NavigationParameters Parameters, bool ShowBack) + { + return InternalNavigate(Type, Parameters, ShowBack, false); + } + + protected virtual bool InternalNavigate(Type Type, NavigationParameters Parameters, bool ShowBack, bool ClearBackStack) { var activity = CurrentActivity; var intent = new Intent(activity, Type); intent.PutExtra("ShowBack", ShowBack); - if (!string.IsNullOrWhiteSpace(Parameter)) + + if (Parameters != null) { - intent.PutExtra("Parameter", Parameter); + var param = JsonConvert.SerializeObject(Parameters); + intent.PutExtra(ParameterKey, param); } + if (ClearBackStack) { intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask); @@ -65,15 +75,25 @@ protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBa return true; } - public override string Parameter + public override NavigationParameters Parameters { get { - var intent = CurrentActivity?.Intent; - return intent?.GetStringExtra("Parameter"); + try + { + var intent = CurrentActivity?.Intent; + var param = intent?.GetStringExtra(ParameterKey); + return JsonConvert.DeserializeObject(param); + } + catch + { + return null; + } } } private Activity CurrentActivity => AndroidHelpers.GetCurrentActivity(); + + private const string ParameterKey = "Parameters"; } } \ No newline at end of file diff --git a/Platform/Platforms/Android/Services/AndroidFragmentNavigator.cs b/Platform/Platforms/Android/Services/AndroidFragmentNavigator.cs index 18a1aa1..46e0817 100644 --- a/Platform/Platforms/Android/Services/AndroidFragmentNavigator.cs +++ b/Platform/Platforms/Android/Services/AndroidFragmentNavigator.cs @@ -12,6 +12,7 @@ using Android.App; using PlatformBindings.Common; +using PlatformBindings.Models; namespace PlatformBindings.Services { @@ -24,10 +25,10 @@ public abstract class AndroidFragmentNavigator : Navigator /// Parameter to remember after the Navigation. /// Removes the ability to go to the previous Fragment. /// Navigation Handled - protected bool NavigatePrimaryFragment(Fragment Fragment, string Parameter, bool ClearBackStack) + protected bool NavigatePrimaryFragment(Fragment Fragment, NavigationParameters Parameters, bool ClearBackStack) { var currentNavigationActivity = Manager.PrimaryNavigationFragment; - _Parameter = Parameter; + _Parameters = Parameters; var transaction = Manager.BeginTransaction(); transaction.Replace(currentNavigationActivity.Id, Fragment); @@ -40,12 +41,12 @@ protected bool NavigatePrimaryFragment(Fragment Fragment, string Parameter, bool return true; } - public override string Parameter => _Parameter; + public override NavigationParameters Parameters => _Parameters; /// /// Parameter Storage, as Fragment Navigation doesn't natively support Parameters that I'm aware of. /// - protected string _Parameter { get; set; } + protected NavigationParameters _Parameters { get; set; } public FragmentManager Manager => AndroidHelpers.GetCurrentActivity().FragmentManager; } diff --git a/Platform/Platforms/Android/Services/Compat/AndroidCompatFragmentNavigator.cs b/Platform/Platforms/Android/Services/Compat/AndroidCompatFragmentNavigator.cs index e2308c9..97f38a3 100644 --- a/Platform/Platforms/Android/Services/Compat/AndroidCompatFragmentNavigator.cs +++ b/Platform/Platforms/Android/Services/Compat/AndroidCompatFragmentNavigator.cs @@ -13,6 +13,7 @@ using Android.Support.V4.App; using Android.Support.V7.App; using PlatformBindings.Common; +using PlatformBindings.Models; namespace PlatformBindings.Services.Compat { @@ -25,10 +26,10 @@ public abstract class AndroidCompatFragmentNavigator : Navigator /// Parameter to remember after the Navigation. /// Removes the ability to go to the previous Fragment. /// Navigation Handled - protected bool NavigatePrimaryFragment(Fragment Fragment, string Parameter, bool ClearBackStack) + protected bool NavigatePrimaryFragment(Fragment Fragment, NavigationParameters Parameters, bool ClearBackStack) { var currentNavigationActivity = Manager.PrimaryNavigationFragment; - _Parameter = Parameter; + _Parameters = Parameters; var transaction = Manager.BeginTransaction(); transaction.Replace(currentNavigationActivity.Id, Fragment); @@ -41,12 +42,12 @@ protected bool NavigatePrimaryFragment(Fragment Fragment, string Parameter, bool return true; } - public override string Parameter => _Parameter; + public override NavigationParameters Parameters => _Parameters; /// /// Parameter Storage, as Fragment Navigation doesn't natively support Parameters that I'm aware of. /// - protected string _Parameter { get; set; } + protected NavigationParameters _Parameters { get; set; } public FragmentManager Manager => ((AppCompatActivity)AndroidHelpers.GetCurrentActivity())?.SupportFragmentManager; } diff --git a/Platform/Platforms/UWP/Services/UWPNavigator.cs b/Platform/Platforms/UWP/Services/UWPNavigator.cs index 23d34e2..e2b29fe 100644 --- a/Platform/Platforms/UWP/Services/UWPNavigator.cs +++ b/Platform/Platforms/UWP/Services/UWPNavigator.cs @@ -10,7 +10,9 @@ // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. // ****************************************************************** +using Newtonsoft.Json; using PlatformBindings.Common; +using PlatformBindings.Models; using System; using Windows.UI.Xaml.Controls; @@ -26,14 +28,24 @@ public UWPNavigator(Frame Frame) private void Frame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) { - _Parameter = (string)e.Parameter; + var param = (string)e.Parameter; + _Parameters = param != null ? JsonConvert.DeserializeObject(param) : null; } - protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBackButton = false, bool ClearBackStack = false) + protected virtual bool InternalNavigate(Type Type, NavigationParameters Parameters, bool ShowBackButton = false, bool ClearBackStack = false) { PlatformBindingHelpers.OnUIThread(() => { - Frame.Navigate(Type, Parameter); + if (Parameters != null) + { + var parameterStr = JsonConvert.SerializeObject(Parameters); + Frame.Navigate(Type, parameterStr); + } + else + { + Frame.Navigate(Type); + } + AppServices.Current.UI.NavigationManager.ShowBackButton = ShowBackButton; if (ClearBackStack) Frame.BackStack.Clear(); @@ -41,8 +53,8 @@ protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBa return true; } - public override string Parameter => _Parameter; - private string _Parameter; + public override NavigationParameters Parameters => _Parameters; + private NavigationParameters _Parameters; private Frame Frame { get; } } diff --git a/Platform/Platforms/Win32/Services/Win32Navigator.cs b/Platform/Platforms/Win32/Services/Win32Navigator.cs index 485909c..e638352 100644 --- a/Platform/Platforms/Win32/Services/Win32Navigator.cs +++ b/Platform/Platforms/Win32/Services/Win32Navigator.cs @@ -10,10 +10,10 @@ // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. // ****************************************************************** +using Newtonsoft.Json; using PlatformBindings.Common; +using PlatformBindings.Models; using System; -using System.Collections.Generic; -using System.Text; using System.Windows.Controls; namespace PlatformBindings.Services @@ -28,16 +28,25 @@ public Win32Navigator(Frame Frame) private void Frame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { - _Parameter = (string)e.ExtraData; + var param = (string)e.ExtraData; + _Parameters = param != null ? JsonConvert.DeserializeObject(param) : null; } - protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBackButton = false, bool ClearBackStack = false) + protected virtual bool InternalNavigate(Type Type, NavigationParameters Parameters, bool ShowBackButton = false, bool ClearBackStack = false) { PlatformBindingHelpers.OnUIThread(() => { var page = Activator.CreateInstance(Type); + if (Parameters != null) + { + var parameterStr = JsonConvert.SerializeObject(Parameters); + Frame.Navigate(page, parameterStr); + } + else + { + Frame.Navigate(page); + } - Frame.Navigate(page, Parameter); AppServices.Current.UI.NavigationManager.ShowBackButton = ShowBackButton; if (ClearBackStack) @@ -51,8 +60,8 @@ protected virtual bool InternalNavigate(Type Type, string Parameter, bool ShowBa return true; } - public override string Parameter => _Parameter; - private string _Parameter; + public override NavigationParameters Parameters => _Parameters; + private NavigationParameters _Parameters; private Frame Frame { get; } } diff --git a/TestApps/Android/Test-Android/Services/TestAndroidNavigator.cs b/TestApps/Android/Test-Android/Services/TestAndroidNavigator.cs index 08d197f..7783c9b 100644 --- a/TestApps/Android/Test-Android/Services/TestAndroidNavigator.cs +++ b/TestApps/Android/Test-Android/Services/TestAndroidNavigator.cs @@ -15,12 +15,13 @@ using System; using System.Linq; using PlatformBindings.Services; +using PlatformBindings.Models; namespace Test_Android.Services { public class TestAndroidNavigator : AndroidActivityNavigator { - public override bool Navigate(TestNavigationPage Page, string Parameter, bool ClearBackStack) + public override bool Navigate(TestNavigationPage Page, NavigationParameters Parameters, bool ClearBackStack) { var pageType = TestService.TestRegister.FirstOrDefault(item => item.Value.Key == Page); if (pageType.HasValue) @@ -33,7 +34,12 @@ public override bool Navigate(TestNavigationPage Page, string Parameter, bool Cl protected bool InternalNavigate(Type Type, bool ShowBack) { - return InternalNavigate(typeof(TestViewer), Type.AssemblyQualifiedName, ShowBack); + var param = new NavigationParameters + { + { "type", Type.AssemblyQualifiedName } + }; + + return InternalNavigate(typeof(TestViewer), param, ShowBack); } } } \ No newline at end of file diff --git a/TestApps/Android/Test-Android/Views/TestViewer.cs b/TestApps/Android/Test-Android/Views/TestViewer.cs index 7f76c3f..167381b 100644 --- a/TestApps/Android/Test-Android/Views/TestViewer.cs +++ b/TestApps/Android/Test-Android/Views/TestViewer.cs @@ -31,8 +31,8 @@ protected override void OnCreate(Bundle savedInstanceState) base.OnCreate(savedInstanceState); try { - var param = TestService.Navigation.Parameter; - var type = Type.GetType(param); + var param = TestService.Navigation.Parameters; + var type = Type.GetType(param["type"]); TestModel = (TestPage)Activator.CreateInstance(type, new AndroidTestPageGenerator(this)); if (TestModel.PageName != null) AppServices.Current.UI.TitleManager.PageTitle = TestModel.PageName; TestModel.DisplayTests(); diff --git a/TestApps/Tests-Universal/TestGenerator/TestTask.cs b/TestApps/Tests-Universal/TestGenerator/TestTask.cs index c3922f6..29f3c8d 100644 --- a/TestApps/Tests-Universal/TestGenerator/TestTask.cs +++ b/TestApps/Tests-Universal/TestGenerator/TestTask.cs @@ -20,8 +20,16 @@ public class TestTask : ITestItem { public async void RunTest() { - var result = await Test(AttachedUI); - if (result != null) AppServices.Current.UI.PromptUser("Test Complete", result, "OK"); + try + { + var result = await Test(AttachedUI); + if (result != null) AppServices.Current.UI.PromptUser("Test Complete", result, "OK"); + } + catch (Exception ex) + { + var message = $"Test Caused exception: \n{ex.Message}\nStackTrace:\n{ex.StackTrace}"; + AppServices.Current.UI.PromptUser("Test Failed", message, "OK"); + } } public string Name { get; set; } diff --git a/TestApps/UWP/Test-UWP/Services/TestUWPNavigator.cs b/TestApps/UWP/Test-UWP/Services/TestUWPNavigator.cs index 9367317..5af75ab 100644 --- a/TestApps/UWP/Test-UWP/Services/TestUWPNavigator.cs +++ b/TestApps/UWP/Test-UWP/Services/TestUWPNavigator.cs @@ -16,6 +16,7 @@ using Windows.UI.Xaml.Controls; using System.Linq; using PlatformBindings.Services; +using PlatformBindings.Models; namespace Test_UWP.Services { @@ -25,7 +26,7 @@ public TestUWPNavigator(Frame Frame) : base(Frame) { } - public override bool Navigate(TestNavigationPage Page, string Parameter, bool ClearBackStack) + public override bool Navigate(TestNavigationPage Page, NavigationParameters Parameters, bool ClearBackStack) { var pageType = TestService.TestRegister.FirstOrDefault(item => item.Value.Key == Page); if (pageType.HasValue) @@ -38,7 +39,12 @@ public override bool Navigate(TestNavigationPage Page, string Parameter, bool Cl protected bool InternalNavigate(Type Type, bool ShowBack) { - return InternalNavigate(typeof(TestViewer), Type.AssemblyQualifiedName, ShowBack); + var param = new NavigationParameters + { + { "type", Type.AssemblyQualifiedName } + }; + + return InternalNavigate(typeof(TestViewer), param, ShowBack); } } } \ No newline at end of file diff --git a/TestApps/UWP/Test-UWP/Views/TestViewer.xaml.cs b/TestApps/UWP/Test-UWP/Views/TestViewer.xaml.cs index bdc6b16..2a8c60a 100644 --- a/TestApps/UWP/Test-UWP/Views/TestViewer.xaml.cs +++ b/TestApps/UWP/Test-UWP/Views/TestViewer.xaml.cs @@ -48,8 +48,8 @@ private void DisplayTests() { try { - var param = TestService.Navigation.Parameter; - var type = Type.GetType(param); + var param = TestService.Navigation.Parameters; + var type = Type.GetType(param["type"]); TestModel = (TestPage)Activator.CreateInstance(type, new UWPTestPageGenerator(this)); if (TestModel.PageName != null) AppServices.Current.UI.TitleManager.WindowTitle = TestModel.PageName; TestModel.DisplayTests(); diff --git a/TestApps/WPF/Test-WPF/MainWindow.xaml b/TestApps/WPF/Test-WPF/MainWindow.xaml index b9b7aef..9fc4f54 100644 --- a/TestApps/WPF/Test-WPF/MainWindow.xaml +++ b/TestApps/WPF/Test-WPF/MainWindow.xaml @@ -5,6 +5,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Test_WPF" mc:Ignorable="d" - Title="MainWindow" Height="350" Width="525"> + Title="Platform Bindings Test App" Height="350" Width="525"> \ No newline at end of file diff --git a/TestApps/WPF/Test-WPF/Services/TestWPFNavigator.cs b/TestApps/WPF/Test-WPF/Services/TestWPFNavigator.cs index d4377ad..41c59ba 100644 --- a/TestApps/WPF/Test-WPF/Services/TestWPFNavigator.cs +++ b/TestApps/WPF/Test-WPF/Services/TestWPFNavigator.cs @@ -10,6 +10,7 @@ // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. // ****************************************************************** +using PlatformBindings.Models; using PlatformBindings.Services; using System; using System.Linq; @@ -25,7 +26,7 @@ public TestWPFNavigator(Frame Frame) : base(Frame) { } - public override bool Navigate(TestNavigationPage Page, string Parameter, bool ClearBackStack) + public override bool Navigate(TestNavigationPage Page, NavigationParameters Parameters, bool ClearBackStack) { var pageType = TestService.TestRegister.FirstOrDefault(item => item.Value.Key == Page); if (pageType.HasValue) @@ -38,7 +39,12 @@ public override bool Navigate(TestNavigationPage Page, string Parameter, bool Cl protected bool InternalNavigate(Type Type, bool ShowBack) { - return InternalNavigate(typeof(TestViewer), Type.AssemblyQualifiedName, ShowBack); + var param = new NavigationParameters + { + { "type", Type.AssemblyQualifiedName } + }; + + return InternalNavigate(typeof(TestViewer), param, ShowBack); } } -} +} \ No newline at end of file diff --git a/TestApps/WPF/Test-WPF/Views/TestViewer.xaml.cs b/TestApps/WPF/Test-WPF/Views/TestViewer.xaml.cs index 9fa2975..bbc2e29 100644 --- a/TestApps/WPF/Test-WPF/Views/TestViewer.xaml.cs +++ b/TestApps/WPF/Test-WPF/Views/TestViewer.xaml.cs @@ -35,8 +35,8 @@ private void DisplayTests() { try { - var param = TestService.Navigation.Parameter; - var type = Type.GetType(param); + var param = TestService.Navigation.Parameters; + var type = Type.GetType(param["type"]); TestModel = (TestPage)Activator.CreateInstance(type, new WPFTestPageGenerator(this)); if (TestModel.PageName != null) Title = TestModel.PageName; TestModel.DisplayTests(); diff --git a/version.json b/version.json index e758fea..8c6bd49 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "0.2.15-alpha", + "version": "0.2.16-alpha", "publicReleaseRefSpec": [ "^refs/heads/master$", // we release out of master "^refs/heads/v\\d+\\.\\d+" // we also release branches starting with vN.N