mvvm 绑定textbox焦点丢失问题

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


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


解决办法:

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

原文地址:https://www.cnblogs.com/swarb/p/9924324.html