diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2017-03-03 06:51:28 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-03-03 12:51:28 +0000 |
commit | b53ccf0d474f4c4d4a2679a8c7ab6c793cc2458d (patch) | |
tree | e24870a94b0bd9fce33f52dc84627ac6ceb14c38 | |
parent | bc13d3cfeeea62214f0c6f434e5f21f7117e2e1a (diff) | |
download | xamarin-forms-b53ccf0d474f4c4d4a2679a8c7ab6c793cc2458d.tar.gz xamarin-forms-b53ccf0d474f4c4d4a2679a8c7ab6c793cc2458d.tar.bz2 xamarin-forms-b53ccf0d474f4c4d4a2679a8c7ab6c793cc2458d.zip |
[WinRT/UWP] Do not allow IsPresented use in Split mode on desktop (#707)
4 files changed, 119 insertions, 1 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51236.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51236.cs new file mode 100644 index 00000000..46737414 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51236.cs @@ -0,0 +1,104 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 51236, "[WinRT/UWP] Setting a MasterDetailPage's IsPresented to false should not be allowed in Split mode", PlatformAffected.WinRT)] + public class Bugzilla51236 : TestMasterDetailPage + { + protected override void Init() + { + var listView = new ListView + { + ItemsSource = new string[] { "A", "B", "C" }, + ItemTemplate = new DataTemplate(() => + { + var cell = new ViewCell(); + cell.View = new StackLayout + { + Children = + { + new Label { Text = "Click to set IsPresented to false" } + } + }; + return cell; + }), + }; + + IsPresented = false; + listView.ItemTapped += (s, e) => + { + IsPresented = false; + listView.SelectedItem = null; + Detail = new ContentPage + { + Title = "Detail", + Content = new StackLayout + { + Children = + { + new Button + { + Text = "Set IsPresented to true", + Command = new Command(() => IsPresented = true) + } + } + } + }; + }; + + Master = new ContentPage + { + Title = "Master", + Content = new StackLayout + { + Children = + { + listView, + new Button + { + Text = "Set MasterBehavior to Popover", + Command = new Command(() => + { + MasterBehavior = MasterBehavior.Popover; + IsPresented = false; + }) + }, + new Button + { + Text = "Set MasterBehavior to Split", + Command = new Command(() => MasterBehavior = MasterBehavior.Split) + }, + new Button + { + Text = "Set MasterBehavior to SplitOnLandscape", + Command = new Command(() => MasterBehavior = MasterBehavior.SplitOnLandscape) + }, + } + } + }; + + Detail = new ContentPage + { + Title = "Detail", + Content = new StackLayout + { + Children = + { + new Button + { + Text = "Set IsPresented to true", + Command = new Command(() => IsPresented = true) + } + } + } + }; + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 72c310fc..4490cf07 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -172,6 +172,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla47923.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla48236.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla47971.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51236.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51238.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51642.xaml.cs"> <DependentUpon>Bugzilla51642.xaml</DependentUpon> diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs index 4a7fe033..b2b0d8b3 100644 --- a/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/MasterDetailPageRenderer.cs @@ -163,7 +163,7 @@ namespace Xamarin.Forms.Platform.UWP protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == MasterDetailPage.IsPresentedProperty.PropertyName) + if (e.PropertyName == MasterDetailPage.IsPresentedProperty.PropertyName || e.PropertyName == MasterDetailPage.MasterBehaviorProperty.PropertyName) UpdateIsPresented(); else if (e.PropertyName == "Master") UpdateMaster(); @@ -286,6 +286,11 @@ namespace Xamarin.Forms.Platform.UWP void UpdateIsPresented() { + // Ignore the IsPresented value being set to false for Split mode on desktop and allow the master + // view to be made initially visible + if (Device.Idiom == TargetIdiom.Desktop && Control.IsPaneOpen && Element.MasterBehavior != MasterBehavior.Popover) + return; + Control.IsPaneOpen = Element.IsPresented; } diff --git a/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs index dcef680e..dfeb3921 100644 --- a/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/MasterDetailPageRenderer.cs @@ -168,7 +168,10 @@ namespace Xamarin.Forms.Platform.WinRT else if (e.PropertyName == MasterDetailPage.IsPresentedProperty.PropertyName) UpdateIsPresented(); else if (e.PropertyName == MasterDetailPage.MasterBehaviorProperty.PropertyName) + { UpdateBehavior(); + UpdateIsPresented(); + } else if (e.PropertyName == Page.TitleProperty.PropertyName) UpdateTitle(); } @@ -276,6 +279,11 @@ namespace Xamarin.Forms.Platform.WinRT void UpdateIsPresented() { + // Ignore the IsPresented value being set to false for Split mode on desktop and allow the master + // view to be made initially visible + if ((Device.Idiom == TargetIdiom.Desktop || Device.Idiom == TargetIdiom.Tablet) && _container.IsMasterVisible && !Element.IsPresented && Element.MasterBehavior != MasterBehavior.Popover) + return; + UpdateBehavior(); bool isPresented = !GetIsMasterAPopover() || Element.IsPresented; |