###前提・実現したいこと
添付したソースのままだと、下図のように各セルの右上に小さい文字が期待通り表示されるのですが、
return new ViewCellのところをコメントアウトしている方に切り替えて、横2段組になるように表示すると、小さい文字が下の文字列の長さに合わせて表示されてしまっています。(上図のように右上に表示させたい)
2段組の上の図のように右上に表示させるためにはどのようにすればよろしいでしょうか?
###該当のソースコード
using System; using System.Collections.Generic; using Xamarin.Forms; namespace XXXXX { public class Test2Page : ContentPage { struct Data { public string textA { get; set; } public string textB { get; set; } public string time { get; set; } }; public Test2Page() { var ar = new List<Data>(); ar.Add( new Data { textA = "あいうえおかきくけこ", textB = "阿", time = "1970-01-01 00:00:00", }); ar.Add( new Data { textA = "さしすせそ", textB = "伊", time = "1980-02-02 22:22:22", }); ar.Add( new Data { textA = "いろはにほへと", textB = "宇", time = "1990-03-03 03:33:33", }); var listView = new ListView { ItemsSource = ar, HasUnevenRows = true, }; listView.ItemTemplate = new DataTemplate(() => { var textA = new Label() { FontSize = 20, }; textA.SetBinding(Label.TextProperty, "textA"); var textB = new Label() { FontSize = 20, }; textB.SetBinding(Label.TextProperty, "textB"); var time = new Label() { FontSize = 10, HorizontalTextAlignment = TextAlignment.End, }; time.SetBinding(Label.TextProperty, "time"); return new ViewCell { //View = new StackLayout //{ // Orientation = StackOrientation.Horizontal, // Children = { // textB, // new StackLayout { // Children = { // time, // textA, // }, // }, // }, //}, View = new StackLayout { Children = { time, textA, textB, }, }, }; }); Content = new StackLayout { Children = { listView, }, }; } } }
###試したこと
View = new StackLayout { Children = { time, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { textB, new StackLayout { Children = { textA, }, }, }, }, }, },
のように上下2段、かつ下段を左右2段に分ける方法ではうまくいくので、左右2段のままできるかの質問になります。
###補足情報(言語/FW/ツール等のバージョンなど)
Xamarin 6.3(build 864)
Mac Note Pro
OS X Yosemite(10.10.5)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/07 02:27