From 76033a4444c936136010bdefbffd75884ce223c3 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Sun, 12 Feb 2017 10:19:13 +0100 Subject: [PATCH 1/3] Changed Pages property to be accessible from XAML --- .../NControl.Controls/WizardLayout.cs | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/NControl.Controls/NControl.Controls/WizardLayout.cs b/NControl.Controls/NControl.Controls/WizardLayout.cs index 94fdb43..f1de666 100644 --- a/NControl.Controls/NControl.Controls/WizardLayout.cs +++ b/NControl.Controls/NControl.Controls/WizardLayout.cs @@ -5,6 +5,7 @@ using System.Collections.Specialized; using System.Collections.Generic; using System.Linq; +using System.Collections.ObjectModel; namespace NControl.Controls { @@ -15,15 +16,9 @@ public class WizardLayout: Grid { #region Private Members - /// - /// The page. - /// - private readonly WizardStackLayout _contentStack; - - /// - /// The pager. - /// - private readonly PagingView _pager; + readonly WizardStackLayout _contentStack; + readonly PagingView _pager; + readonly ObservableCollection _pages = new ObservableCollection(); #endregion @@ -32,6 +27,8 @@ public class WizardLayout: Grid /// public WizardLayout() { + _pages.CollectionChanged += PagesChanged; + // Wrapping layout var layout = new RelativeLayout(); Children.Add(layout); @@ -83,35 +80,14 @@ public int Page } } - /// - /// The pages property. - /// - public static BindableProperty PagesProperty = BindableProperty.Create(nameof(Pages), - typeof(IEnumerable), typeof(WizardLayout), null, propertyChanged: (bindable, oldValue, newValue) => { - var ctrl = (WizardLayout)bindable; - ctrl.Pages = (IEnumerable)newValue; - }); - /// /// Gets or sets the pages. /// /// The pages. - public IEnumerable Pages - { - get { return (IEnumerable)GetValue(PagesProperty); } - set - { - if (Pages != null && Pages is INotifyCollectionChanged) - (Pages as INotifyCollectionChanged).CollectionChanged -= PagesChanged; - - SetValue(PagesProperty, value); - - if (Pages != null && Pages is INotifyCollectionChanged) - (Pages as INotifyCollectionChanged).CollectionChanged += PagesChanged; - - UpdatePages(); - } - } + public IList Pages + { + get { return _pages; } + } #endregion From 30168fdcfc52218263aa9a44e2dedb2a80e09a19 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Sun, 12 Feb 2017 10:20:21 +0100 Subject: [PATCH 2/3] Updated example with XAML file to verify that xaml works for the WizardLayout. --- .../NControl.Controls.Demo.FormsApp/MyApp.cs | 1 + .../NControl.Controls.Demo.FormsApp.csproj | 6 ++++++ .../WizardPage.cs | 6 ++++-- .../WizardPageXaml.xaml | 15 +++++++++++++++ .../WizardPageXaml.xaml.cs | 16 ++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml create mode 100644 NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml.cs diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/MyApp.cs b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/MyApp.cs index 29b3745..3918499 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/MyApp.cs +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/MyApp.cs @@ -27,6 +27,7 @@ public MyApp () new SvgImagePage(), new CalendarPage(), new WizardPage(), + new WizardPageXaml(), new RepeaterPage(), }; diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/NControl.Controls.Demo.FormsApp.csproj b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/NControl.Controls.Demo.FormsApp.csproj index ef46ee1..1697afb 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/NControl.Controls.Demo.FormsApp.csproj +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/NControl.Controls.Demo.FormsApp.csproj @@ -52,6 +52,9 @@ + + WizardPageXaml.xaml + @@ -65,6 +68,9 @@ + + MSBuild:UpdateDesignTimeXaml + diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs index b5a958d..0d20eae 100644 --- a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs @@ -14,8 +14,9 @@ protected override void OnAppearing () { base.OnAppearing (); - var wizard = new WizardLayout (); - wizard.Pages = new View[]{ + WizardLayout wizard = null; + wizard = new WizardLayout { + Pages = { new Button { Command = new Command((obj)=>wizard.Page++), Text = "Page 2", @@ -34,6 +35,7 @@ protected override void OnAppearing () new Button { Text = "Done", } + } }; Content = wizard; diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml new file mode 100644 index 0000000..119a76c --- /dev/null +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml.cs b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml.cs new file mode 100644 index 0000000..fe5b148 --- /dev/null +++ b/NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPageXaml.xaml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace NControl.Controls.Demo.FormsApp +{ + public partial class WizardPageXaml : ContentPage + { + public WizardPageXaml() + { + InitializeComponent(); + Title = "WizardLayout XAML"; + } + } +} From b6408c35d08b33098b6aa0d63bffee1009cda5b7 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Sun, 12 Feb 2017 10:20:58 +0100 Subject: [PATCH 3/3] Closes #28 --- NControl.Controls/NControl.Controls/WizardLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NControl.Controls/NControl.Controls/WizardLayout.cs b/NControl.Controls/NControl.Controls/WizardLayout.cs index f1de666..6857f8c 100644 --- a/NControl.Controls/NControl.Controls/WizardLayout.cs +++ b/NControl.Controls/NControl.Controls/WizardLayout.cs @@ -86,7 +86,7 @@ public int Page /// The pages. public IList Pages { - get { return _pages; } + get { return _pages; } } #endregion