2011-07-18 81 views
0

我需要一個按鈕單擊觸發器,它將更改邊框的可見性屬性。情況是一個登錄屏幕,邊框中顯示一條錯誤消息,當登錄被單擊時,邊界在執行登錄邏輯之前崩潰(理想情況)。在執行綁定到登錄按鈕Command屬性的邏輯之前,我無法使用EventTriggers路由MouseLeftButtonUp/Down事件來更新UI。使用按鈕觸發器設置邊框可見性屬性

+0

您是否嘗試過包含對象(例如,您的窗口)上的UpdateLayout來強制更新佈局? –

回答

0

通過使用強制更新UI的方法解決了該問題。

void AllowUIToUpdate() 
{ 
    DispatcherFrame frame = new DispatcherFrame(); 

    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render 
              , new DispatcherOperationCallback(delegate(object parameter) 
                { 
                 frame.Continue = false; 
                 return null; 
                }) 
              , null); 

    Dispatcher.PushFrame(frame); 
}