开发者

Set Border Visibility Property Using Button Trigger

开发者 https://www.devze.com 2023-03-20 23:31 出处:网络
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 b

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消