WPF等待窗口 [英] WPF wait window

查看:630
本文介绍了WPF等待窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想运行长时间操作时,我想显示模型对话框窗口(等待窗口)

When i want to run Long Operation i want to show model dialog window (Wait Window)

我想在另一个线程中将此Show Window显示为ShowDialog()

I want to display this Wait Window in different Thread as ShowDialog()

在进入长时间运行"操作之前,我将显示模型对话框"窗口

Before entering into Long Running Operation, i will display Model Dialog Window

完成长时间运行操作后,我将关闭此模型对话框窗口

After done with Long Running Operation, i will close this Model Dialog Window

我知道,除了在另一个线程中创建窗口外,我们还可以在另一个线程中移动长时间运行的代码,但是这对我的代码影响很大.

I know instead of creating Window in another Thread, we can simply move long Running Code in another Thread but impact of this in my code is heavy.

请为我建议一个解决方案

Please suggest me a solution for this

推荐答案

我建议您避免使用诸如ShowDialog()调用之类的WinForms气味解决方案. 看看现成的 WPF ToolKit BusyIndi​​cator ,它可以利用功能和灵活性WPF和XAML.

I would suggest you to avoid such WinForms-smell solutions like ShowDialog() calls. Take a look at the out of the box WPF ToolKit BusyIndicator it alows leverage a power and flexibility of WPF and XAML.

BusyIndi​​cator可让用户轻松知道何时应用程序 忙.只需将相关内容包装在 BusyIndi​​cator控件,在执行过程中将其IsBusy属性切换为True 任何长时间运行的过程.

BusyIndicator makes it easy to let the user know when an application is busy. Simply wrap the relevant content in an instance of the BusyIndicator control and toggle its IsBusy property to True during any long-running process.

它允许建立自定义的等待窗口,例如:

It allows build custom wait windows, for instance:

您可以完全控制UI布局,并且可以定义自己的DataTemplate:

You have full control of UI layout and can define your own DataTemplate:

<extToolkit:BusyIndicator IsBusy="True" DisplayAfter="0">
       <extToolkit:BusyIndicator.BusyContentTemplate>
            <DataTemplate>
               ....

有关更多示例和下载,请参见扩展的WPF工具包BusyIndi​​cator .

See Extended WPF Toolkit BusyIndicator for more examples and download.

这篇关于WPF等待窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆