尽管 UI 组件的 Visibility 绑定到 ViewModel 属性并且实现了该属性的 PropertyChanged,但 UI 是否有可能跳过自身更新?
查看/XAML:
<Border Visibility="{Binding ShowLoadingPanel, Converter={StaticResource BoolToHiddenConverter}}">
<TextBlock Text="LOADING..." />
</Border>
视图模型:
Public Property ShowLoadingPanel As Boolean
Get
Return _showLoadingPanel
End Get
Set(value As Boolean)
_showLoadingPanel = value
OnPropertyChanged("ShowLoadingPanel")
End Set
End Property
从 ViewModel 运行以下命令时:
ShowLoadingPanel = True
RunBigTask() 'runs a task that takes a long time
ShowLoadingPanel = False
... XAML 中定义的边框不可见。
但是如果我添加一些需要用户交互的东西,例如:
ShowLoadingPanel = True
MsgBox("Click to continue")
RunBigTask() 'runs a task that takes a long time
ShowLoadingPanel = False
...然后边框根据需要变为可见。
这怎么可能?