makes the ctor dependent of its viewmodel

vnext
Paul Schneider 8 years ago
parent ec546348d9
commit 828772cd6f
2 changed files with 18 additions and 22 deletions

@ -1,4 +1,5 @@
using System; using BookAStar.ViewModels;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -10,9 +11,10 @@ namespace BookAStar.Pages
{ {
public partial class EditBillingLinePage : ContentPage public partial class EditBillingLinePage : ContentPage
{ {
public EditBillingLinePage() public EditBillingLinePage(BillingLineViewModel model)
{ {
InitializeComponent(); InitializeComponent();
BindingContext = model;
} }
} }
} }

@ -1,5 +1,6 @@
using BookAStar.Model; using BookAStar.Model;
using BookAStar.Model.Workflow; using BookAStar.Model.Workflow;
using BookAStar.ViewModels;
using BookAStar.Views; using BookAStar.Views;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,6 +9,9 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Forms.Services;
using XLabs.Ioc;
using XLabs.Platform.Services;
namespace BookAStar.Pages namespace BookAStar.Pages
{ {
@ -16,43 +20,33 @@ namespace BookAStar.Pages
public Estimate Estimate { get { return BindingContext as Estimate; } set { public Estimate Estimate { get { return BindingContext as Estimate; } set {
BindingContext = value; BindingContext = value;
} } } }
public static readonly BindableProperty TotalProperty =
BindableProperty.Create("Total", typeof(decimal), typeof(EditEstimatePage),
(decimal) 0, BindingMode.OneWay);
public static readonly BindableProperty DescriptionProperty =
BindableProperty.Create("Description", typeof(string), typeof(Estimate),
null, BindingMode.TwoWay);
public static readonly BindableProperty ClientProperty =
BindableProperty.Create("Client", typeof(ClientProviderInfo), typeof(Estimate),
null, BindingMode.OneWay);
public static readonly BindableProperty QueryProperty =
BindableProperty.Create("Query", typeof(BookQueryData), typeof(Estimate),
null, BindingMode.OneWay);
public EditEstimatePage(EstimateViewModel model)
public EditEstimatePage()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = model;
} }
protected override void OnBindingContextChanged() protected override void OnBindingContextChanged()
{ {
base.OnBindingContextChanged(); base.OnBindingContextChanged();
// FIXME Why the Binding don't work? // FIXME WAZA
mdview.Markdown = Estimate.Description; if (BindingContext != null)
mdview.Markdown = ((EstimateViewModel)BindingContext).Description;
} }
protected void OnDescriptionChanged (object sender, EventArgs e) protected void OnDescriptionChanged (object sender, EventArgs e)
{ {
// FIXME Why the Binding don't work? // FIXME Why the Binding don't work?
Estimate.Description = mdview.Markdown; ((EstimateViewModel)BindingContext).Description = mdview.Markdown;
} }
protected void OnNewCommanLine(object sender, EventArgs e) protected void OnNewCommanLine(object sender, EventArgs e)
{ {
var com = new BillingLine(); var com = new BillingLine();
App.CurrentApp.EditCommandLine(this,com); Resolver.Resolve<INavigationService>().NavigateTo<EditBillingLinePage>(
true,
new object[] { new BillingLineViewModel(com) } );
} }
} }

Loading…