简体   繁体   English

绑定视图模型以查看

[英]Bind View model to view

I have general question about binding in the view of the view model. 我在视图模型的视图中有关于绑定的一般性问题。

We are working on wizard and in the initialize page all the pages are called before the wizard starts (see the code below) so in the view we are using the following code to do the relation with this.Datacontext = mvm; 我们正在使用向导,并且在初始化页面中,所有页面都在向导启动之前被调用(请参见下面的代码),因此在视图中,我们正在使用以下代码来与this.Datacontext = mvm;建立关系this.Datacontext = mvm; , currently when this code is called the objects in the view model which bind to the screen (from the viewModel ) is empty since this called in the beginning of the pages creation but the view model will be updated with data later in the program. ,当前,当调用此代码时,绑定到屏幕的视图模型中的对象(从viewModel )为空,因为在页面创建开始时调用了该对象,但是视图模型将在程序的后面用数据更新。

Will the screen be updated with the data when the bounded items are filled? 填充边界项时,是否将用数据更新屏幕?

 public partial class EPreviewGraphSelector : UserControl
        {
           MyViewModel mvm = new viewModel(); 
            public EPreviewGraphSelector()
            {
                InitializeComponent();
                this.Datacontext = mvm;
            }
        }

does the screen will be updated with the data when the bounded items is filled ? 填充边界项目时,屏幕是否将使用数据更新?

Provided your ViewModel implements INotifyPropertyChanged correctly, the UI should update. 如果您的ViewModel正确实现INotifyPropertyChanged ,则UI应该更新。

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

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