diff options
Diffstat (limited to 'Xamarin.Forms.Controls')
-rw-r--r-- | Xamarin.Forms.Controls/ControlGalleryPages/NativeBindingGalleryPage.cs | 101 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/CoreGallery.cs | 3 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj | 1 |
3 files changed, 104 insertions, 1 deletions
diff --git a/Xamarin.Forms.Controls/ControlGalleryPages/NativeBindingGalleryPage.cs b/Xamarin.Forms.Controls/ControlGalleryPages/NativeBindingGalleryPage.cs new file mode 100644 index 00000000..51d9b970 --- /dev/null +++ b/Xamarin.Forms.Controls/ControlGalleryPages/NativeBindingGalleryPage.cs @@ -0,0 +1,101 @@ +using System; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls +{ + public class NativeBindingGalleryPage : ContentPage + { + public StackLayout Layout { get; set; } + public bool NativeControlsAdded { get; set; } + + NestedNativeViewModel ViewModel { get; set; } + + public NativeBindingGalleryPage() + { + + var vm = new NestedNativeViewModel(); + vm.FormsLabel = "Forms Label Binding"; + vm.NativeLabel = "Native Label Binding"; + vm.NativeLabelColor = Color.Red; + vm.Age = 45; + + Layout = new StackLayout { Padding = 20, VerticalOptions = LayoutOptions.FillAndExpand }; + + var buttonNav = new Button { Text = "New Page" }; + buttonNav.Clicked += (object sender, EventArgs e) => + { + App.Current.MainPage = new ContentPage { Content = new Label { Text = "New page" } }; + }; + + var button = new Button { Text = "Change BindingContext " }; + button.Clicked += (object sender, EventArgs e) => + { + vm = new NestedNativeViewModel(); + vm.FormsLabel = "Forms Label Binding Changed"; + vm.NativeLabel = "Native Label Binding Changed"; + vm.NativeLabelColor = Color.Pink; + vm.Age = 10; + + BindingContext = ViewModel = vm; ; + }; + + var boxView = new BoxView { HeightRequest = 50 }; + boxView.SetBinding(BoxView.BackgroundColorProperty, "NativeLabelColor"); + + var label = new Label(); + label.SetBinding(Label.TextProperty, "FormsLabel"); + + Layout.Children.Add(buttonNav); + + Layout.Children.Add(label); + + Layout.Children.Add(boxView); + Layout.Children.Add(button); + + BindingContext = ViewModel = vm; ; + + Content = new ScrollView { Content = Layout }; + } + } + + + [Preserve(AllMembers = true)] + public class NestedNativeViewModel : ViewModelBase + { + string _formsLabel; + public string FormsLabel + { + get { return _formsLabel; } + set { _formsLabel = value; OnPropertyChanged(); } + } + + string _nativeLabel; + public string NativeLabel + { + get { return _nativeLabel; } + set { _nativeLabel = value; OnPropertyChanged(); } + } + + Color _nativeLabelColor; + public Color NativeLabelColor + { + get { return _nativeLabelColor; } + set { _nativeLabelColor = value; OnPropertyChanged(); } + } + + int _age; + public int Age + { + get { return _age; } + set { _age = value; OnPropertyChanged(); } + } + + bool _selected; + public bool Selected + { + get { return _selected; } + set { _selected = value; OnPropertyChanged(); } + } + } + +} diff --git a/Xamarin.Forms.Controls/CoreGallery.cs b/Xamarin.Forms.Controls/CoreGallery.cs index 7986a45c..06f214b4 100644 --- a/Xamarin.Forms.Controls/CoreGallery.cs +++ b/Xamarin.Forms.Controls/CoreGallery.cs @@ -221,6 +221,7 @@ namespace Xamarin.Forms.Controls { var pages = new List<Page> { new PlatformSpecificsGallery() {Title = "Platform Specifics"}, + new NativeBindingGalleryPage {Title = "Native Binding Controls Gallery"}, new AppLinkPageGallery {Title = "App Link Page Gallery"}, new NestedNativeControlGalleryPage {Title = "Nested Native Controls Gallery"}, new CellForceUpdateSizeGalleryPage {Title = "Cell Force Update Size Gallery"}, @@ -446,4 +447,4 @@ namespace Xamarin.Forms.Controls return new CoreNavigationPage (); } } -}
\ No newline at end of file +} diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj index 825d157d..3b02adbe 100644 --- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj +++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj @@ -235,6 +235,7 @@ <Compile Include="ControlGalleryPages\AppearingGalleryPage.cs" /> <Compile Include="ControlGalleryPages\AutomationIDGallery.cs" /> <Compile Include="GalleryPages\AppLinkPageGallery.cs" /> + <Compile Include="ControlGalleryPages\NativeBindingGalleryPage.cs" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.targets" /> |