이 단추에서 스팸 클릭을 거부하는 단추를 비활성화하려고합니다.코드로 WPF- 컨트롤 새로 고침
렌더링 대리인 새로 고침을 사용하여 컨트롤을 호출했지만 활성화 된 것으로 나타납니다. connect() - 버튼이 활성화 된 것으로 표시되는 약 4 초가 걸립니다.
어디에 문제가 있습니까?
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate() { };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
}
private void buttonConnect_Click(object sender, RoutedEventArgs e)
{
this.Cursor = Cursors.Wait;
buttonConnect.IsEnabled = false;
buttonConnect.Refresh();
if (buttonConnect.Content.Equals("Connect"))
{
connect();
}
else
{
disconnect();
}
buttonConnect.IsEnabled = true;
buttonConnect.Refresh();
this.Cursor = Cursors.Arrow;
}
+1 내가 본 많은 해제합니다. 이것은 제가 본 가장 유연하고 믿을만한 것입니다. –