【问题标题】:Put text to Label - Xamarin.Forms将文本放入标签 - Xamarin.Forms
【发布时间】:2017-04-13 17:22:42
【问题描述】:

如何将新文本放入 xamarin.forms 中的标签?

如果我在 XAML 中有这个:

 <Label   Text="{Binding Nombre}" Font="Bold,16" x:Name="tNombre"  TextColor="{StaticResource ColorBlanco}" Style="{StaticResource TextAligment}"/>

但是要输入新文本:代码中的情况如何?:我必须使用什么?...我是新来的。

【问题讨论】:

  • 您能否将视图中 c# 部分的代码添加到您的问题中?
  • 在页面中使用 tNombre.Text = "someText";
  • 尝试按照@mww 的方式进行操作,但出现错误:System.NullReferenceException: Object reference not set to an instance of an object

标签: xamarin data-binding binding label xamarin.forms


【解决方案1】:

您显示的标签绑定到 Nombre 字段。

<Label   Text="{Binding Nombre}"

只要你绑定的类实现了 INotifyPropertyChanged 接口,改变你绑定的类中 Nombre 的值就应该更新 UI

【讨论】:

  • 您能否更新您的答案以更清楚。我如何实现 INotifyPropertyChanged
猜你喜欢
  • 1970-01-01
  • 2018-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-08
  • 2017-07-21
  • 1970-01-01
  • 2018-05-24
相关资源
最近更新 更多