[英]Textblock binding text
I want to display the string _lunedi in a textbox, the string _lunedi is updated periodically using InitializeBoxes().我想在文本框中显示字符串 _lunedi,使用 InitializeBoxes() 定期更新字符串 _lunedi。
I have my class:我有我的课:
public event PropertyChangedEventHandler PropertyChanged;
private string _lunedi= "lunedi ";
public string lunedi
{
get { return this._lunedi; }
set
{
if (value != this._lunedi)
{
this._lunedi = value;
NotifyPropertyChanged("lunedi");
}
}
}
public void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
whit this method change the lunedi:这个方法改变了lunedi:
private void InitializeBoxes()
{
lunedi += todayPivot.Day;
}
xaml: xml:
<Border>
<TextBlock Text="{Binding Path=lunedi, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</Border>
The problem is that the text of the textblock is empty.问题是文本块的文本是空的。 Thank you.
谢谢你。
Sounds like the binding is using one time try this instead听起来绑定正在使用一次试试这个
<Border>
<TextBlock Text="{Binding Path=lunedi, Mode=OneWay}"></TextBlock>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.