在我的xaml
我有一个 Button 和一个 TextBlock
<TextBlock Text="{Binding AText}" FontSize="20"/>
<Button Content="Click" Command="{Binding MyCommand}" Grid.Row="1"/>
在我的 ViewModel 我有以下代码
let aText = self.Factory.Backing(<@ self.AText @>, "Initial Text")
let asyncTask x = async {
self.AText <- "Loading"
do! Async.Sleep(5000)
self.AText <- "Loaded"
}
member self.AText with get() = aText.Value and set(v) = aText.Value <- v
member self.MyCommand = self.Factory.CommandAsyncChecked(asyncTask, fun _ -> true)
当我单击该按钮时,它会被禁用并保持不变,直到完成asyncTask
. 我认为设置canExecute
astrue
会改变行为,但事实并非如此!
如何控制按钮的行为?