
(此代码有效,但TextBlock未更新)
XAML
<TextBlock x:name="filterallText" Text="{Binding UpdateSourceTrigger=PropertyChanged}" /> 代码隐藏
filterallText.DataContext = LogSession.test.MyCoynt;
C#
public class Test : INotifyPropertyChanged { public int myCoynt; public int MyCoynt { get { return myCoynt; } set { myCoynt = value; NotifyPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual voID NotifyPropertyChanged( [CallerMembername] String propertyname = "") { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this,new PropertyChangedEventArgs(propertyname)); }}解决方法 试试这个: <TextBlock x:name="filterallText" Text="{Binding UpdateSourceTrigger=PropertyChanged,Path=MyCoynt}" /> 并将您的DataContext设置为:
filterallText.DataContext = LogSession.test;总结
以上是内存溢出为你收集整理的c# – WPF TextBlock文本绑定全部内容,希望文章能够帮你解决c# – WPF TextBlock文本绑定所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)