2017-03-14 59 views
1

我在Xamarin表單應用中有一個列表視圖,我的一個標籤可以有一個非常長的一組文本。問題在於文本被切斷,標籤的高度從來沒有多線。沒有在列表視圖中設置單元格高度

我可以多行嗎? 我可以讓身高更高嗎?

以下是我的代碼。我嘗試過在幾個地方調整高度,但沒有一個讓這個單元變大。

   //  each item; it must return a Cell derivative.) 
       ItemTemplate = new DataTemplate(() => 
       { 
        // Create views with bindings for displaying each property. 
        Xamarin.Forms.Label nameLabel = new Xamarin.Forms.Label(); 
        nameLabel.SetBinding(Xamarin.Forms.Label.TextProperty, 
         new Binding("Name", BindingMode.OneWay, 
         null, null, "{0}")); 

        Xamarin.Forms.Label yearLabel = new Xamarin.Forms.Label(); 
        yearLabel.SetBinding(Xamarin.Forms.Label.TextProperty, 
         new Binding("Birthday", BindingMode.OneWay, 
          null, null, "FMI {0:yyyy}")); 

        Xamarin.Forms.Label componentLabel = new Xamarin.Forms.Label(); 
        componentLabel.SetBinding(Xamarin.Forms.Label.TextProperty, 
         new Binding("Component", BindingMode.OneWay, 
          null, null, "Component: {0}")); 

        Xamarin.Forms.Label descriptionLabel = new Xamarin.Forms.Label(); 
        descriptionLabel.SetBinding(Xamarin.Forms.Label.TextProperty, 
         new Binding("Description", BindingMode.OneWay, 
          null, null, "{0}")); 
        descriptionLabel.HorizontalOptions = LayoutOptions.FillAndExpand; 

        descriptionLabel.LineBreakMode = LineBreakMode.NoWrap; 
        descriptionLabel.HeightRequest = 256.0; 
        descriptionLabel.MinimumHeightRequest = 250.0; 

        BoxView boxView = new BoxView(); 
        boxView.SetBinding(BoxView.ColorProperty, "SeverityColor"); 
        boxView.MinimumHeightRequest = 100.0; 
        boxView.MinimumHeightRequest = 100.0; 

        // Return an assembled ViewCell. 
        return new ViewCell 
        { 
         View = new StackLayout 
         { 
          Padding = new Thickness(0, 2), 
          Orientation = StackOrientation.Horizontal, 
          HeightRequest = 155.0, 
          MinimumHeightRequest = 155.0, 
          Children = 
           { 
            boxView, 
            new StackLayout 
            { 
             VerticalOptions = LayoutOptions.Center, 
             HorizontalOptions = LayoutOptions.Fill, 
             Spacing = 0, 
             HeightRequest = 235.0, 
             MinimumHeightRequest = 250.0, 

             Children = 
             { 
              componentLabel, 
              descriptionLabel 
             } 
            } 
           } 
         },Height = 250 
        }; 
       }) 

回答

2

我看不到如何定義ListView。有時

listview.HasUnevenRows = true; 

幫助

HasUnevenRows

+0

這就是我需要的。我的行都太大,但是需要該屬性來履行行高請求。謝謝 – Maestro1024

0

我經歷放在StackLayout與水平方向的多線標籤的一個奇怪的行爲。

請在Xamarin Forms論壇中參閱my comment

相關問題