2015-10-15 24 views
0

我需要在UWP中使用setrowspan()方法。 它存在於UWP中? 嘗試:SetRowSpan找不到在uwp

tod.SetValue(Grid.RowProperty, 0); 
tod.SetValue(Grid.ColumnProperty, i + 1); 
DayNameGrid.SetRowSpan(tod,2); 

我得到一個編譯錯誤:

CS0176 C# Member 'Grid.SetRowSpan(FrameworkElement, int)' cannot be accessed with an instance reference; qualify it with a type name instead

回答

1

的方法是靜態的,你想這樣稱呼它一個實例方法。

Grid.SetRowSpan(tod, 2); 

別擔心,它會自動應用到元素的父網格(簡單地說)。

注意,您可以使用相同的語法其他屬性,如果你喜歡:

Grid.SetRow(tod, 0); 
Grid.SetColumn(tod, i + 1); 
1

這是告訴你,該方法是一個靜態方法,所以你應該把它作爲奧赫。

Grid.SetRowSpan(tod,2);