Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个注册屏幕,当用户单击“注册”按钮时,会发生一个异步操作,最后会调用一个委托方法。我希望在用户单击按钮时关闭按钮(这部分很容易),并且如果注册失败(服务器拒绝注册)重新启用按钮。如何从委托功能访问此按钮的属性?
假设您已经在 XAML 中声明了 Button 的名称,在委托回调函数中,我会执行类似的操作(Dispatcher.BeginInvoke 是在 UI 线程上执行代码所必需的):
Dispatcher.BeginInvoke(() => { MyRegisterButton.IsEnabled = true; });