WP7 Silverlight网格不显示内容 [英] WP7 Silverlight grid not showing content

查看:121
本文介绍了WP7 Silverlight网格不显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WP7上与SL网格进行了2个小时的斗争。我使用下面的代码构建我的网格:




public void initUIBoard(){
int x,y;
Button b;

  for(x = 0; x  RowDefinition rd = new RowDefinition(); 
rd.Height = new GridLength(20);
uiBoard.RowDefinitions.Add(rd);


$ b for(y = 0; y ColumnDefinition cd = new ColumnDefinition();
cd.Width = new GridLength(20);
uiBoard.ColumnDefinitions.Add(cd); (x = 0; x for(y = 0; y< mine.cColumns; y ++;
}



{
b = new Button();
b.Click + = new RoutedEventHandler(this.caseClick);

b.Tag = mine.gameBoard [x] [y];
Grid.SetRow(b,x);
Grid.SetColumn(b,y);

uiBoard.Children.Add(b);
}

}



事情是,我的网格显示为空,我是在做这些行/列定义还是错? b

预先感谢

解决方案

经过一些实验后,它看起来像 GridLength 不是以像素为单位正确计算高度。

因为创建的网格单元不够大,所以没有显示控件。



尝试增加用于网格长度的大小。我做了以下,并得到了一些输出。

  rd.Height = new GridLength(40); 

或者,考虑将高度和宽度设置为动态调整大小。例如:

  rd.Height = new GridLength(1,GridUnitType.Auto); 

如果您可以调查这个高度问题并且发现它是高度问题,那么请将其提交给Microsoft。


It's been 2 hours of struggle against SL grid on WP7. I build my grid using the following code:

public void initUIBoard() { int x, y; Button b;

        for (x = 0; x < mine.cRows; x++) {
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(20);
            uiBoard.RowDefinitions.Add(rd);
        }


        for (y = 0; y < mine.cColumns; y++) {
            ColumnDefinition cd = new ColumnDefinition();
            cd.Width = new GridLength(20);
            uiBoard.ColumnDefinitions.Add(cd);
        }


        for (x = 0; x < mine.cRows; x++)
            for (y = 0; y < mine.cColumns; y++)
            {
                b = new Button();
                b.Click += new RoutedEventHandler(this.caseClick);

                b.Tag = mine.gameBoard[x][y];
                Grid.SetRow(b, x);
                Grid.SetColumn(b, y);

                uiBoard.Children.Add(b);
            }

    }

The thing is, my grid is shown empty, am I doing something wrong with these Rows/Columns definition or something ?

Thanks in advance

解决方案

After some experimentation, it looks like GridLength isn't calculating heights in pixels correctly.
Because the grid cell created isn't large enough the control is not shown.

Try increasing the sizes used for grid length. I did the following and got some output.

rd.Height = new GridLength(40);

Alternatively, consider setting the Heights and Widths to by dynamically sized. e.g.:

rd.Height = new GridLength(1, GridUnitType.Auto);

If you can investigate this height issue some more and also find it to be a height issue bug then please submit it to Microsoft.

这篇关于WP7 Silverlight网格不显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆