Skip to content

Commit

Permalink
Merge branch 'Feature/28-WizardLayoutXAMLSupport' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
chrfalch committed Feb 12, 2017
2 parents 508fa2d + b6408c3 commit 8ac87d7
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 36 deletions.
44 changes: 10 additions & 34 deletions NControl.Controls/NControl.Controls/WizardLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Collections.ObjectModel;

namespace NControl.Controls
{
Expand All @@ -15,15 +16,9 @@ public class WizardLayout: Grid
{
#region Private Members

/// <summary>
/// The page.
/// </summary>
private readonly WizardStackLayout _contentStack;

/// <summary>
/// The pager.
/// </summary>
private readonly PagingView _pager;
readonly WizardStackLayout _contentStack;
readonly PagingView _pager;
readonly ObservableCollection<View> _pages = new ObservableCollection<View>();

#endregion

Expand All @@ -32,6 +27,8 @@ public class WizardLayout: Grid
/// </summary>
public WizardLayout()
{
_pages.CollectionChanged += PagesChanged;

// Wrapping layout
var layout = new RelativeLayout();
Children.Add(layout);
Expand Down Expand Up @@ -83,35 +80,14 @@ public int Page
}
}

/// <summary>
/// The pages property.
/// </summary>
public static BindableProperty PagesProperty = BindableProperty.Create(nameof(Pages),
typeof(IEnumerable<View>), typeof(WizardLayout), null, propertyChanged: (bindable, oldValue, newValue) => {
var ctrl = (WizardLayout)bindable;
ctrl.Pages = (IEnumerable<View>)newValue;
});

/// <summary>
/// Gets or sets the pages.
/// </summary>
/// <value>The pages.</value>
public IEnumerable<View> Pages
{
get { return (IEnumerable<View>)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<View> Pages
{
get { return _pages; }
}

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public MyApp ()
new SvgImagePage(),
new CalendarPage(),
new WizardPage(),
new WizardPageXaml(),
new RepeaterPage(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<Compile Include="SvgImagePage.cs" />
<Compile Include="WizardPage.cs" />
<Compile Include="RepeaterPage.cs" />
<Compile Include="WizardPageXaml.xaml.cs">
<DependentUpon>WizardPageXaml.xaml</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ItemGroup>
Expand All @@ -65,6 +68,9 @@
<EmbeddedResource Include="Resources\Svg\Smile.svg" />
<EmbeddedResource Include="Resources\Svg\Arrows.svg" />
<EmbeddedResource Include="Resources\Svg\SpaceShips.svg" />
<EmbeddedResource Include="WizardPageXaml.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="NGraphics">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -34,6 +35,7 @@ protected override void OnAppearing ()
new Button {
Text = "Done",
}
}
};

Content = wizard;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ncontrols="clr-namespace:NControl.Controls;assembly=NControl.Controls"
x:Class="NControl.Controls.Demo.FormsApp.WizardPageXaml">
<ContentPage.Content>
<ncontrols:WizardLayout>
<ncontrols:WizardLayout.Pages>
<ContentView><Label Text="Page 1"/></ContentView>
<ContentView><Label Text="Page 1"/></ContentView>
</ncontrols:WizardLayout.Pages>
</ncontrols:WizardLayout>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -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";
}
}
}

0 comments on commit 8ac87d7

Please sign in to comment.