Update UI async?

前端 未结 3 593
故里飘歌
故里飘歌 2021-01-13 19:28

Consider this example:

Private Sub Button_Click(
    sender As Button, e As RoutedEventArgs) Handles btn.Click

  sender.IsEnabled = False

  Thread.Sleep(50         


        
3条回答
  •  时光说笑
    2021-01-13 19:59

    Bind the button enabled property to a property in your VM (say ProcessComplete).

    Use the button onclick event to trigger a method in your VM that starts up your long winded process. Keep the ProcessComplete False whilst the process is running and then set it True when it completes.

提交回复
热议问题