简体   繁体   English

带有MVVM模式的windows 8手机应用程序,用于textchanged和clickCommand序列

[英]windows 8 phone app with MVVM pattern for textchanged vs clickCommand sequence

I am facing an issue for wizard kind of screen, user enters text in textbox and clicks on "go to Next Screen", then "go to Next Screen" related command fires prior to "text-changed" of required field and user gets annoyed message to enter data where data is already in textbox but sequence of events firing is making a problem. 我面临向导类屏幕的问题,用户在文本框中输入文本并点击“转到下一屏幕”,然后“转到下一屏幕”相关命令在所需字段的“文本更改”之前触发,用户生气输入数据的消息,其中数据已经在文本框中,但是事件序列触发正在产生问题。 Can i make sure to fire "text-changed" property first and then click command? 我可以确保首先触发“text-changed”属性然后单击命令吗?

<TextBox  Text="{Binding UserName,Mode=TwoWay}"></TextBox>


public RelayCommand<String> NavigateToCommand
        {
            get
            {
                return _navigateToCommand
                    ?? (_navigateToCommand = new RelayCommand<String>(
                        pw =>
                        {
if (String.IsNullOrWhiteSpace(this.UserName))
            {
                message = "UserName is required ";
            }
}}}

只需更改源触发器。

Text="{Binding UserName,Mode=TwoWay,UpdateSourceTrigger=OnPropertyChanged}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM