Skip to content

Commit 8ac87d7

Browse files
committed
Merge branch 'Feature/28-WizardLayoutXAMLSupport' into develop
2 parents 508fa2d + b6408c3 commit 8ac87d7

6 files changed

Lines changed: 52 additions & 36 deletions

File tree

NControl.Controls/NControl.Controls/WizardLayout.cs

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Specialized;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Collections.ObjectModel;
89

910
namespace NControl.Controls
1011
{
@@ -15,15 +16,9 @@ public class WizardLayout: Grid
1516
{
1617
#region Private Members
1718

18-
/// <summary>
19-
/// The page.
20-
/// </summary>
21-
private readonly WizardStackLayout _contentStack;
22-
23-
/// <summary>
24-
/// The pager.
25-
/// </summary>
26-
private readonly PagingView _pager;
19+
readonly WizardStackLayout _contentStack;
20+
readonly PagingView _pager;
21+
readonly ObservableCollection<View> _pages = new ObservableCollection<View>();
2722

2823
#endregion
2924

@@ -32,6 +27,8 @@ public class WizardLayout: Grid
3227
/// </summary>
3328
public WizardLayout()
3429
{
30+
_pages.CollectionChanged += PagesChanged;
31+
3532
// Wrapping layout
3633
var layout = new RelativeLayout();
3734
Children.Add(layout);
@@ -83,35 +80,14 @@ public int Page
8380
}
8481
}
8582

86-
/// <summary>
87-
/// The pages property.
88-
/// </summary>
89-
public static BindableProperty PagesProperty = BindableProperty.Create(nameof(Pages),
90-
typeof(IEnumerable<View>), typeof(WizardLayout), null, propertyChanged: (bindable, oldValue, newValue) => {
91-
var ctrl = (WizardLayout)bindable;
92-
ctrl.Pages = (IEnumerable<View>)newValue;
93-
});
94-
9583
/// <summary>
9684
/// Gets or sets the pages.
9785
/// </summary>
9886
/// <value>The pages.</value>
99-
public IEnumerable<View> Pages
100-
{
101-
get { return (IEnumerable<View>)GetValue(PagesProperty); }
102-
set
103-
{
104-
if (Pages != null && Pages is INotifyCollectionChanged)
105-
(Pages as INotifyCollectionChanged).CollectionChanged -= PagesChanged;
106-
107-
SetValue(PagesProperty, value);
108-
109-
if (Pages != null && Pages is INotifyCollectionChanged)
110-
(Pages as INotifyCollectionChanged).CollectionChanged += PagesChanged;
111-
112-
UpdatePages();
113-
}
114-
}
87+
public IList<View> Pages
88+
{
89+
get { return _pages; }
90+
}
11591

11692
#endregion
11793

NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/MyApp.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public MyApp ()
2727
new SvgImagePage(),
2828
new CalendarPage(),
2929
new WizardPage(),
30+
new WizardPageXaml(),
3031
new RepeaterPage(),
3132
};
3233

NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/NControl.Controls.Demo.FormsApp.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
<Compile Include="SvgImagePage.cs" />
5353
<Compile Include="WizardPage.cs" />
5454
<Compile Include="RepeaterPage.cs" />
55+
<Compile Include="WizardPageXaml.xaml.cs">
56+
<DependentUpon>WizardPageXaml.xaml</DependentUpon>
57+
</Compile>
5558
</ItemGroup>
5659
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
5760
<ItemGroup>
@@ -65,6 +68,9 @@
6568
<EmbeddedResource Include="Resources\Svg\Smile.svg" />
6669
<EmbeddedResource Include="Resources\Svg\Arrows.svg" />
6770
<EmbeddedResource Include="Resources\Svg\SpaceShips.svg" />
71+
<EmbeddedResource Include="WizardPageXaml.xaml">
72+
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
73+
</EmbeddedResource>
6874
</ItemGroup>
6975
<ItemGroup>
7076
<Reference Include="NGraphics">

NControl.ControlsDemo/NControl.Controls.Demo.FormsApp/WizardPage.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ protected override void OnAppearing ()
1414
{
1515
base.OnAppearing ();
1616

17-
var wizard = new WizardLayout ();
18-
wizard.Pages = new View[]{
17+
WizardLayout wizard = null;
18+
wizard = new WizardLayout {
19+
Pages = {
1920
new Button {
2021
Command = new Command((obj)=>wizard.Page++),
2122
Text = "Page 2",
@@ -34,6 +35,7 @@ protected override void OnAppearing ()
3435
new Button {
3536
Text = "Done",
3637
}
38+
}
3739
};
3840

3941
Content = wizard;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ContentPage
3+
xmlns="http://xamarin.com/schemas/2014/forms"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:ncontrols="clr-namespace:NControl.Controls;assembly=NControl.Controls"
6+
x:Class="NControl.Controls.Demo.FormsApp.WizardPageXaml">
7+
<ContentPage.Content>
8+
<ncontrols:WizardLayout>
9+
<ncontrols:WizardLayout.Pages>
10+
<ContentView><Label Text="Page 1"/></ContentView>
11+
<ContentView><Label Text="Page 1"/></ContentView>
12+
</ncontrols:WizardLayout.Pages>
13+
</ncontrols:WizardLayout>
14+
</ContentPage.Content>
15+
</ContentPage>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Xamarin.Forms;
5+
6+
namespace NControl.Controls.Demo.FormsApp
7+
{
8+
public partial class WizardPageXaml : ContentPage
9+
{
10+
public WizardPageXaml()
11+
{
12+
InitializeComponent();
13+
Title = "WizardLayout XAML";
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)