From a6a6255bff906e9ea22109ad3dca59801b01fa2f Mon Sep 17 00:00:00 2001 From: Kent Boogaart Date: Sun, 18 Sep 2016 17:52:21 +0930 Subject: [PATCH] Use non-generic BindableProperty.Create. This commit fixes #1159 by switching from the use of the generic BindableProperty.Create method to the non-generic. --- .../XamForms/ReactiveCarouselPage.cs | 8 +++++-- .../XamForms/ReactiveContentPage.cs | 8 +++++-- .../XamForms/ReactiveContentView.cs | 8 +++++-- .../XamForms/ReactiveEntryCell.cs | 8 ++++--- .../XamForms/ReactiveImageCell.cs | 8 ++++--- .../XamForms/ReactiveMasterDetailPage.cs | 8 +++++-- .../XamForms/ReactiveMultiPage.cs | 8 +++++-- .../XamForms/ReactiveNavigationPage.cs | 8 +++++-- .../XamForms/ReactiveSwitchCell.cs | 8 ++++--- .../XamForms/ReactiveTabbedPage.cs | 8 +++++-- .../XamForms/ReactiveTextCell.cs | 8 ++++--- .../XamForms/ReactiveViewCell.cs | 8 ++++--- .../XamForms/RoutedViewHost.cs | 12 ++++++---- .../XamForms/ViewModelViewHost.cs | 24 ++++++++++++++----- 14 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveCarouselPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveCarouselPage.cs index 246a2e81d2..4b2dcd9aaa 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveCarouselPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveCarouselPage.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveCarouselPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveContentPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveContentPage.cs index 4d354352be..f7303a4ed1 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveContentPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveContentPage.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveContentPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveContentView.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveContentView.cs index fb432b7e13..cd5de1f6b0 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveContentView.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveContentView.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveContentView), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveEntryCell.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveEntryCell.cs index 8eceaf4e53..9493dd550a 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveEntryCell.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveEntryCell.cs @@ -6,9 +6,11 @@ namespace ReactiveUI.XamForms public class ReactiveEntryCell : EntryCell, IViewFor where TViewModel : class { - public static readonly BindableProperty ViewModelProperty = BindableProperty.Create, TViewModel>( - x => x.ViewModel, - null, + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveEntryCell), + default(TViewModel), BindingMode.OneWay); public TViewModel ViewModel diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveImageCell.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveImageCell.cs index 0b307301a7..4e4b881962 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveImageCell.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveImageCell.cs @@ -6,9 +6,11 @@ namespace ReactiveUI.XamForms public class ReactiveImageCell : ImageCell, IViewFor where TViewModel : class { - public static readonly BindableProperty ViewModelProperty = BindableProperty.Create, TViewModel>( - x => x.ViewModel, - null, + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveImageCell), + default(TViewModel), BindingMode.OneWay); public TViewModel ViewModel diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveMasterDetailPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveMasterDetailPage.cs index f351139d6b..1a3213732d 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveMasterDetailPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveMasterDetailPage.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveMasterDetailPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveMultiPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveMultiPage.cs index a8985b296e..2370dc16da 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveMultiPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveMultiPage.cs @@ -15,8 +15,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveMultiPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveNavigationPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveNavigationPage.cs index 9b2999d870..69c75a62a1 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveNavigationPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveNavigationPage.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveNavigationPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveSwitchCell.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveSwitchCell.cs index 3fd42f8651..0bdbace832 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveSwitchCell.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveSwitchCell.cs @@ -6,9 +6,11 @@ namespace ReactiveUI.XamForms public class ReactiveSwitchCell : SwitchCell, IViewFor where TViewModel : class { - public static readonly BindableProperty ViewModelProperty = BindableProperty.Create, TViewModel>( - x => x.ViewModel, - null, + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveSwitchCell), + default(TViewModel), BindingMode.OneWay); public TViewModel ViewModel diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveTabbedPage.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveTabbedPage.cs index 0d8697d23f..c95ffa2743 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveTabbedPage.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveTabbedPage.cs @@ -14,8 +14,12 @@ public TViewModel ViewModel { get { return (TViewModel)GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create, TViewModel>(x => x.ViewModel, default(TViewModel), BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveTabbedPage), + default(TViewModel), + BindingMode.OneWay); object IViewFor.ViewModel { get { return ViewModel; } diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveTextCell.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveTextCell.cs index 093ee63ce3..efe4bdbedd 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveTextCell.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveTextCell.cs @@ -6,9 +6,11 @@ namespace ReactiveUI.XamForms public class ReactiveTextCell : TextCell, IViewFor where TViewModel : class { - public static readonly BindableProperty ViewModelProperty = BindableProperty.Create, TViewModel>( - x => x.ViewModel, - null, + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveTextCell), + default(TViewModel), BindingMode.OneWay); public TViewModel ViewModel diff --git a/src/ReactiveUI.XamForms/XamForms/ReactiveViewCell.cs b/src/ReactiveUI.XamForms/XamForms/ReactiveViewCell.cs index 50dd3cf235..606116a4eb 100644 --- a/src/ReactiveUI.XamForms/XamForms/ReactiveViewCell.cs +++ b/src/ReactiveUI.XamForms/XamForms/ReactiveViewCell.cs @@ -6,9 +6,11 @@ namespace ReactiveUI.XamForms public class ReactiveViewCell : ViewCell, IViewFor where TViewModel : class { - public static readonly BindableProperty ViewModelProperty = BindableProperty.Create, TViewModel>( - x => x.ViewModel, - null, + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactiveViewCell), + default(TViewModel), BindingMode.OneWay); public TViewModel ViewModel diff --git a/src/ReactiveUI.XamForms/XamForms/RoutedViewHost.cs b/src/ReactiveUI.XamForms/XamForms/RoutedViewHost.cs index 2f750924b2..6e1e68611d 100644 --- a/src/ReactiveUI.XamForms/XamForms/RoutedViewHost.cs +++ b/src/ReactiveUI.XamForms/XamForms/RoutedViewHost.cs @@ -11,8 +11,12 @@ namespace ReactiveUI.XamForms { public class RoutedViewHost : NavigationPage, IActivatable { - public static readonly BindableProperty RouterProperty = BindableProperty.Create( - x => x.Router, null, BindingMode.OneWay); + public static readonly BindableProperty RouterProperty = BindableProperty.Create( + nameof(Router), + typeof(RoutingState), + typeof(RoutedViewHost), + default(RoutingState), + BindingMode.OneWay); public RoutingState Router { get { return (RoutingState)GetValue(RouterProperty); } @@ -75,7 +79,7 @@ public RoutedViewHost() }) .Do(_ => ((IViewFor)this.CurrentPage).ViewModel = Router.GetCurrentViewModel()) .Subscribe()); - + d(this.WhenAnyObservable(x => x.Router.Navigate) .SelectMany(_ => PageForViewModel(Router.GetCurrentViewModel())) .SelectMany(async x => { @@ -135,7 +139,7 @@ public RoutedViewHost() .Subscribe(); } - protected IObservable PageForViewModel(IRoutableViewModel vm) + protected IObservable PageForViewModel(IRoutableViewModel vm) { if (vm == null) return Observable.Empty(); diff --git a/src/ReactiveUI.XamForms/XamForms/ViewModelViewHost.cs b/src/ReactiveUI.XamForms/XamForms/ViewModelViewHost.cs index ac946e3aed..01f16c833a 100644 --- a/src/ReactiveUI.XamForms/XamForms/ViewModelViewHost.cs +++ b/src/ReactiveUI.XamForms/XamForms/ViewModelViewHost.cs @@ -22,8 +22,12 @@ public object ViewModel { get { return GetValue(ViewModelProperty); } set { SetValue(ViewModelProperty, value); } } - public static readonly BindableProperty ViewModelProperty = - BindableProperty.Create(x => x.ViewModel, null, BindingMode.OneWay); + public static readonly BindableProperty ViewModelProperty = BindableProperty.Create( + nameof(ViewModel), + typeof(object), + typeof(ViewModelViewHost), + default(object), + BindingMode.OneWay); /// /// If no ViewModel is displayed, this content (i.e. a control) will be displayed. @@ -32,15 +36,23 @@ public View DefaultContent { get { return (View)GetValue(DefaultContentProperty); } set { SetValue(DefaultContentProperty, value); } } - public static readonly BindableProperty DefaultContentProperty = - BindableProperty.Create(x => x.DefaultContent, null, BindingMode.OneWay); + public static readonly BindableProperty DefaultContentProperty = BindableProperty.Create( + nameof(DefaultContent), + typeof(View), + typeof(ViewModelViewHost), + default(View), + BindingMode.OneWay); public IObservable ViewContractObservable { get { return (IObservable)GetValue(ViewContractObservableProperty); } set { SetValue(ViewContractObservableProperty, value); } } - public static readonly BindableProperty ViewContractObservableProperty = - BindableProperty.Create>(x => x.ViewContractObservable, Observable.Never(), BindingMode.OneWay); + public static readonly BindableProperty ViewContractObservableProperty = BindableProperty.Create( + nameof(ViewContractObservable), + typeof(string), + typeof(ViewModelViewHost), + Observable.Never(), + BindingMode.OneWay); public IViewLocator ViewLocator { get; set; }