A good example on how to use UpdateSourceTrigger=Explicit with MVVM

后端 未结 1 490
臣服心动
臣服心动 2021-01-18 07:07

I\'m trying to figure out how to use UpdateSourceTrigger=Explicit.

I\'ve got following form:



        
1条回答
  •  半阙折子戏
    2021-01-18 07:42

    You need to call BindingExpression.UpdateSource in the code behind to manually update the binding. Explicit binding isn't really compatible with MVVM since you need to directly reference the view objects to perform the manually update.

    // itemNameTextBox is an instance of a TextBox
    BindingExpression be = itemNameTextBox.GetBindingExpression(TextBox.TextProperty);
    be.UpdateSource();
    

    0 讨论(0)
提交回复
热议问题