[Core] Fixes '0*' RowDefinition/ColumnDefinition in Grid (#2926) fixes #2767

This commit is contained in:
Pavel Yakovlev 2018-06-05 22:40:40 +03:00 коммит произвёл Rui Marinho
Родитель a31c51ca01
Коммит 67dfb16f6e
3 изменённых файлов: 54 добавлений и 2 удалений

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

@ -0,0 +1,51 @@
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, 2767, "ArgumentException: NaN not valid for height", PlatformAffected.All)]
public class Issue2767 : TestContentPage
{
protected override void Init()
{
var grid = new Grid
{
RowDefinitions =
{
new RowDefinition { Height = new GridLength(0, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(60, GridUnitType.Star) },
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(0, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(10, GridUnitType.Star) },
}
};
grid.AddChild(new Label { Text = "Collapsed" }, 0, 0);
grid.AddChild(new Label { Text = "Collapsed" }, 0, 1);
grid.AddChild(new Label { Text = "Collapsed" }, 1, 0);
grid.AddChild(new Label { Text = "Label 1:1" }, 1, 1);
Content = new Frame
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
Content = grid
};
}
#if UITEST
[Test]
public void Issue2767Test()
{
RunningApp.WaitForElement("Label 1:1");
Assert.IsEmpty(RunningApp.Query("Collapsed"));
}
#endif
}
}

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

@ -239,6 +239,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59580.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59580.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffect.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffectList.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Effects\AttachedStateEffectList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2767.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GitHub1878.cs" /> <Compile Include="$(MSBuildThisFileDirectory)GitHub1878.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ISampleNativeControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Helpers\ISampleNativeControl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ViewHelper.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Helpers\ViewHelper.cs" />

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

@ -468,7 +468,7 @@ namespace Xamarin.Forms
ColumnDefinition col = _columns[index]; ColumnDefinition col = _columns[index];
if (!col.Width.IsStar) if (!col.Width.IsStar)
continue; continue;
starColWidth = Math.Max(starColWidth, col.ActualWidth / col.Width.Value); starColWidth = col.Width.Value != 0 ? Math.Max(starColWidth, col.ActualWidth / col.Width.Value) : 0;
} }
return starColWidth; return starColWidth;
@ -567,7 +567,7 @@ namespace Xamarin.Forms
RowDefinition row = _rows[index]; RowDefinition row = _rows[index];
if (!row.Height.IsStar) if (!row.Height.IsStar)
continue; continue;
starRowHeight = Math.Max(starRowHeight, row.ActualHeight / row.Height.Value); starRowHeight = row.Height.Value != 0 ? Math.Max(starRowHeight, row.ActualHeight / row.Height.Value) : 0;
} }
return starRowHeight; return starRowHeight;