xaml 将字符串绑定到Text属性
示例
要在运行时更改UI内容,可以使用Binding。从代码更改绑定属性后,它将显示在UI上。
<TextBlock Text="{Binding Title}"/>要通知UI有关更改,属性必须PropertyChanged从INotifyPropertyChanged接口引发事件,或者可以使用DependencyProperty。
如果属性“Title”在xaml.cs文件中或的Datacontext类中,则绑定有效XAML。
数据上下文可以直接在XAML中设置
<Window x:Class="Application.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Application">
<Window.DataContext>
<local:DataContextClass/>
</Window.DataContext>
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短