【发布时间】:2017-04-07 05:36:01
【问题描述】:
这是我的代码:
public ChatItemCell()
{
TextAlignment Ausrichtung = TextAlignment.Start;
var lblBody = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
HorizontalTextAlignment = Ausrichtung,
TextColor = Color.Black
};
lblBody.SetBinding(Label.TextProperty, "Body");
var lblSender = new Label()
{
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
HorizontalTextAlignment = Ausrichtung,
TextColor = Color.Gray,
FontAttributes = FontAttributes.Italic
};
lblSender.SetBinding(Label.TextProperty, "Sender");
var layout = new StackLayout()
{
Opacity = 90,
Orientation = StackOrientation.Vertical,
Children = {lblSender, lblBody}
};
Frame outerFrame = new Frame()
{
Padding = new Thickness(5, 5, 5, 5),
OutlineColor = Color.Accent,
BackgroundColor = Color.Yellow,
Content = layout,
};
Frame objFrame_Outer = new Frame
{
Padding = new Thickness(10, 0, 10, 10),
Content = outerFrame
};
View = objFrame_Outer;
}
我想要的是,TextAligment 取决于“发件人”。意思是:当发件人是“我”时,对齐应该是左,否则应该是右。那么如何获取“Sender”的内容呢?
非常感谢! 克里兹
【问题讨论】:
标签: c# xamarin data-binding binding chat