我必須爲WP8.SDk創建一個表。在動態創建的網格中設置行的背景
我正在爲此使用網格。我創建了一個動態的行和列的網格。
現在我想設置背景圖片,使頭不同..
我的C#代碼是在這裏。
private void table_click(object sender, RoutedEventArgs e)
{
//Creation of Grid
Grid tablegrid = new Grid();
tablegrid.Height = double.NaN;
tablegrid.Width = 454;
tablegrid.Margin = new Thickness(0, 66, 0, 0);
tablegrid.ShowGridLines = true;
tablegrid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
tablegrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
//Table Rows and Columns Definition
string[] tablerow = new string[] { "Submit Report", "Something", "New" };
string[] tablecol = new string[] { "Mansab", "Arsal", "Ali" };
int i, j;
for (i = 0; i < tablerow.Length; i++)
{
RowDefinition gridrows = new RowDefinition();
gridrows.Height = new GridLength(66);
if (i == 0)
{
var brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("Resources/Images/top_bar_bg.png", UriKind.Relative));
//gridrows.Background = brush; //This not works
}
tablegrid.RowDefinitions.Insert(i, gridrows);
}
for (j = 0; j < tablecol.Length; j++)
{
ColumnDefinition gridCol = new ColumnDefinition();
tablegrid.ColumnDefinitions.Insert(j, gridCol);
}
tablegrid.ShowGridLines = true;
ContentPanel.Children.Add(tablegrid);
}
我的表是這樣的:
http://www.4shared.com/download/SlNX8mbpba/Table.PNG
,但我必須做出這樣的事情:
http://www.4shared.com/download/j-qT-kGVce/table2.PNG
如何指定動態每一行的背景是什麼?
我無法爲windows phone 8 sdk使用datagrid。這裏只是網格。我正在嘗試將其用作表格。因此,標題的背景圖像是必要的。如果我能夠爲標題做到這一點,那麼我可以放入所有的行和列..但在這裏我不能..所以你可以解決這個..? – Arsal