2015-08-14 24 views
5

Sana "*" XAML bu yolla satır yüksekliğini ayarlayabilirsiniz biliyoruz:Xamarin Formlar Grid - C# içinde "*" satır yüksekliği?

new RowDefinition { Height = new GridLength("*", GridUnitType.Auto) }, 

Benim soru nasıl:

<RowDefinition Height="Auto" /> 
<RowDefinition Height="*" /> 

ancak C# aynı ifadede hata verir Bir kılavuzun satır yüksekliğini C# cinsinden "*" olarak ayarlamak için?

cevap

12
var grid = new Grid(); 
grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto }); 
grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }); 

var stacklayout1 = new StackLayout { HeightRequest = 100, BackgroundColor = Color.Red }; 
var stacklayout2 = new StackLayout { BackgroundColor = Color.Blue }; 

Grid.SetRow (stacklayout2, 1); 

grid.Children.Add (stacklayout1); 
grid.Children.Add (stacklayout2); 

MainPage = new ContentPage { Content = grid }; 

Screenshot of the above layout on iOS

+1

Teşekkürler, ben de son satır olursa olsun sıranın içeriği ne düzen altına uzatmak hale nasıl? –

İlgili konular