WPF刷新界面的应用技巧是一个非常常用的功能。在实际操作中我们需要对其进行非常熟练的操作。希望这篇文章总介绍的内容可以帮助大家提高对WPF的理解程度。#t#
WPF刷新界面应用代码示例:
- /// <summary>
- /// App.xaml 的交互逻辑
- /// </summary>
- public partial class App : Application
- {
- private static DispatcherOperat
ionCallback exitFrameCallback =
new DispatcherOperationCallback(ExitFrame); - public static void DoEvents()
- {
- DispatcherFrame nestedFrame =
new DispatcherFrame(); - DispatcherOperation exitOperation =
Dispatcher.CurrentDispatcher.BeginInvoke
(DispatcherPriority.Background,
exitFrameCallback, nestedFrame); - Dispatcher.PushFrame(nestedFrame);
- if (exitOperation.Status !=
DispatcherOperationStatus.Completed) - {
- exitOperation.Abort();
- }
- }
- private static Object ExitFrame
(Object state) - {
- DispatcherFrame frame = state as
DispatcherFrame; - frame.Continue = false;
- return null;
- }
- }
WPF刷新界面使用方法就介绍到这里。