mvvm 绑定textbox焦点丢失问题

来源:互联网 发布:彩票数据库中心预测 编辑:程序博客网 时间:2024/06/16 05:56

<TextBoxName="UserNameText"Text="{Binding Path=Username, Mode=TwoWay}"HorizontalContentAlignment="Stretch"/>


此时焦点如果还在textbox上时,后台Username的值仍为NULL


解决办法:

<TextBoxName="UserNameText"Text="{Binding Path=Username, UpdateSourceTrigger=PropertyChanged}"/>

原创粉丝点击