I need a button click trigger that will change the visibility property for a border. The situation is a logon screen with an error message in the border, and whe开发者_JAVA百科n login is clicked the border collapses prior to the logon logic executing (ideally). I am unable to get the UI to update before executing the logic, which is bound to the login button Command property, using EventTriggers routing the MouseLeftButtonUp/Down events.
Solved the problem by using a method to force the UI to update.
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);
}
精彩评论