前提・実現したいこと
以下のような、ラベル4つを1項目としたリストを作りたい。
ーーーーーーーーーーーーーーーー
ラベル1 ラベル3
ラベル2 ラベル4
ーーーーーーーーーーーーーーーー
発生している問題・エラーメッセージ
上記のようにラベルを四隅に配置できません。
ラベル1,2は問題ないのですが、3,4が左詰めになってしまいます。
よろしくお願い致します。
※下記ソースは関係ありそうな部分のみ切り取ったものです
該当のソースコード
C#
1 class Data 2 { 3 public string label1 { get; set; } 4 public string label2 { get; set; } 5 public string label3 { get; set; } 6 public string label4 { get; set; } 7 8 } 9 internal class MyPage : ContentPage 10 { 11 public MyPage() 12 { 13 // List<>からなるデータ取得 14 var list_data = DataGet("test"); 15 // リストビュー 16 var listView = new ListView 17 { 18 ItemsSource = list_data, 19 RowHeight = 60 20 }; 21 22 listView.ItemTemplate = new DataTemplate(() => { 23 var l1 = new Label() { FontSize = 12, HorizontalOptions = LayoutOptions.Start }; 24 l1.SetBinding(Label.TextProperty, "label1"); 25 26 var l2= new Label() { FontSize = 14, HorizontalOptions = LayoutOptions.Start }; 27 l2.SetBinding(Label.TextProperty, "label2"); 28 29 var l3 = new Label() { FontSize = 12, HorizontalOptions = LayoutOptions.End }; 30 l3.SetBinding(Label.TextProperty, "label3"); 31 32 var l4 = new Label() { FontSize = 14, HorizontalOptions = LayoutOptions.End }; 33 l4.SetBinding(Label.TextProperty, "label4"); 34 35 //縦に並べたテキストレイアウトを作成する 36 var textLayout1 = new StackLayout 37 { 38 Children = { l1, l2 } 39 }; 40 var textLayout2 = new StackLayout 41 { 42 Children = { l3, l4} 43 }; 44 45 return new ViewCell 46 { 47 View = new StackLayout 48 { 49 Orientation = StackOrientation.Horizontal, //横に並べる 50 HorizontalOptions = LayoutOptions.FillAndExpand, 51 52 Padding = new Thickness(20, 10, 0, 0), //パディング 53 54 Children = { 55 textLayout1, 56 textLayout2 57 } 58 } 59 }; 60 }); 61 62 //ListViewのみをコンテンツとして配置する 63 Content = listView;
試したこと
補足情報(FW/ツールのバージョンなど)
開発環境:VisualStudio2019
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/20 12:13