页面及时刷新方法

  填坑,上文说的 C# Event.ClickCount 解决垃圾鼠标带来的烦恼 中及时刷新UI方法

如下:

 [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public static void RefreshButtonClickProperty()
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrames), frame);
            try { Dispatcher.PushFrame(frame); }
            catch (InvalidOperationException e)
            {
            }
        }

public static object ExitFrames(object f)
{
((DispatcherFrame)f).Continue = false;

 
    

return null;
}

 

在对控件的某些属性进行设置后可及时调用该方法进行刷新

转载于:https://www.cnblogs.com/Khan-Sadas/p/10059520.html

你可能感兴趣的:(c#,ui)