2017-03-14 25 views
1

私はXamarinフォームアプリケーションでリストビューを持っています。私のラベルの1つに本当に長いテキストセットを入れることができます。問題は、テキストがちょうど途切れてしまい、ラベルの高さが決して複数行にならないことです。リストビューにセルの高さが設定されていません

複数行にすることはできますか? 高さをもっと高くすることはできますか?

以下は私のコードです。私はいくつかの場所で高さを調整しようとしましたが、どれもセルを大きくしていません。

   //  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; 

は、私は水平方向にStackLayoutに配置された複数行のラベルの奇妙な行動を経験した

HasUnevenRows

+0

これは私が必要としていたものです。私の行はすべて大きすぎますが、その行の高さ要求を尊重するためにそのプロパティが必要でした。ありがとう – Maestro1024

0

に役立ちます。

Xamarin Formsフォーラムのmy commentを参照してください。

関連する問題