2016-06-09 95 views
0

我試圖文本換行的按鈕網格內,但只出現在第一行,代碼:xamarin形式:按鈕文本換

grid.Children.Add(new Button { 
    Text = la[0].Floor, 
    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), 
    BorderWidth = 1, 
    HorizontalOptions = LayoutOptions.Center, 
    VerticalOptions = LayoutOptions.CenterAndExpand, 
} , column, row); 

回答

0

你可能需要改變你的Grid.RowDefinitions的高度,以Auto該按鈕被放置在哪個行上。使用Auto而不是GridUnitType.Star應使Button具有儘可能多的高度,因爲它需要顯示其內容。

這就是說,如果文本超長,它仍然可能無法正常工作。

如果該按鈕在第一行上,那麼你會改變該行的Height到:

Grid grid = new Grid { 
    RowDefinitions = new RowDefinitions { 
     new RowDefinition { Height = GridLength.Auto } 
    } 
} 

如果沒有幫助,請出示您的Grid的初始化代碼。