[UWP] Fixes of calculation of heights in the MasterDetailPage (#2924) Fixes #1648

* [UWP] Fixes of calculation of heights in the MasterDetailPage

* addressing comments
This commit is contained in:
Pavel Yakovlev 2018-08-06 17:24:03 +03:00 коммит произвёл Rui Marinho
Родитель a7b4a47396
Коммит 1fe23fff8e
3 изменённых файлов: 66 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,63 @@
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.Github, 1648, "MasterDetailPage throws ArgumentOutOfRangeException", PlatformAffected.UWP)]
public class GitHub1648 : TestNavigationPage
{
protected override void Init()
{
Navigation.PushAsync(new MasterDetailPage
{
Master = new NavigationPage(new ContentPage())
{
Title = "Master"
},
Detail = new ContentPage(),
});
}
protected override void OnAppearing()
{
base.OnAppearing();
Navigation.PushModalAsync(new SimplePage());
}
class SimplePage : ContentPage
{
public SimplePage ()
{
Content = new StackLayout()
{
Children = {
new Label {
Text = "Success"
},
new Button
{
Text = "Reload",
Command = new Command(() => Navigation.PopModalAsync())
}
}
};
}
}
#if UITEST
[Test]
public void GitHub1648Test()
{
RunningApp.WaitForElement("Reload");
RunningApp.Tap("Reload");
RunningApp.WaitForElement("Success");
}
#endif
}
}

Просмотреть файл

@ -243,6 +243,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffectLabel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffectList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub1648.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub1702.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub2598.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1483.cs" />

Просмотреть файл

@ -109,7 +109,7 @@ namespace Xamarin.Forms.Platform.UWP
width -= _masterPresenter.ActualWidth;
}
return new Windows.Foundation.Size(width >= 0 ? width : 0, height);
return new Windows.Foundation.Size(Math.Max(width, 0), Math.Max(height, 0));
}
}
@ -181,7 +181,7 @@ namespace Xamarin.Forms.Platform.UWP
else if (_masterPresenter != null)
width = _masterPresenter.ActualWidth;
return new Windows.Foundation.Size(width, height);
return new Windows.Foundation.Size(Math.Max(width, 0), Math.Max(height, 0));
}
}