Windows phone 8 忽略行定义GridUnitType.Star

Windows phone 8 忽略行定义GridUnitType.Star,windows-phone-8,scrollviewer,Windows Phone 8,Scrollviewer,我有下面的代码,其中我在第1行中放置了一个ScrollViewer,在其他行中放置了按钮和文本。第一行(第0行)正确显示,但ScrollViewer占据了屏幕的其余部分。以下行中的按钮被推离屏幕,不可见。如果我硬编码ScrollViewer的高度,它可以正常工作,但我不想这样做。我的GridUnitType.Star命令似乎被忽略了。我错过了什么 Grid mainGrid = new Grid(); mainGrid.VerticalAlignment = VerticalAlignment.

我有下面的代码,其中我在第1行中放置了一个ScrollViewer,在其他行中放置了按钮和文本。第一行(第0行)正确显示,但ScrollViewer占据了屏幕的其余部分。以下行中的按钮被推离屏幕,不可见。如果我硬编码ScrollViewer的高度,它可以正常工作,但我不想这样做。我的GridUnitType.Star命令似乎被忽略了。我错过了什么

Grid mainGrid = new Grid();
mainGrid.VerticalAlignment = VerticalAlignment.Stretch;
mainGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
mainGrid.ColumnDefinitions.Add(new ColumnDefinition());
for (int i = 0; i < 6; i++)
{
    RowDefinition r = new RowDefinition();
    if (i == 1) // scrollview = 1
    {
        r.Height = new GridLength(1, GridUnitType.Star); // take 100% of the remaining height
        //r = new RowDefinition { Height = new GridLength(300) };
    }
    else
    {
        r.Height = new GridLength(0, GridUnitType.Auto); // wrap the height
    }
    mainGrid.RowDefinitions.Add(r);
}
Grid mainGrid=new Grid();
mainGrid.VerticalAlignment=VerticalAlignment.Stretch;
mainGrid.HorizontalAlignment=HorizontalAlignment.Stretch;
添加(新ColumnDefinition());
对于(int i=0;i<6;i++)
{
RowDefinition r=新的RowDefinition();
如果(i==1)//scrollview=1
{
r、 高度=新的GridLength(1,GridUnitType.Star);//取剩余高度的100%
//r=新的行定义{高度=新的网格长度(300)};
}
其他的
{
r、 高度=新的GridLength(0,GridUnitType.Auto);//换行高度
}
mainGrid.RowDefinitions.Add(r);
}

今天它可以正常工作。我想退出并重新启动visual studio一定重置了某些内容。

是否尝试在ScrollViewer中设置
VerticalScrollBarVisibility=“Auto”