不能在WPF应用程序中使用DoEvents [英] Cant use DoEvents in WPF application

查看:168
本文介绍了不能在WPF应用程序中使用DoEvents的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB中的VSTS 2008 RTM中有一个WPF应用程序。我正试图

眨眼 (暂时清除)数据字段,如果数据重新加载

从数据库中给用户一些视觉指示LOAD

操作。


所以在LOAD按钮上我清除文本字段,执行

mainCanvas.UpdateLayout(),然后从

数据库重新加载文本字段。但文本字段的清除时间不足以查看它们

闪烁。


所以我在重新加载文本字段之前添加一个Thread.Sleep(200)。还是

没有视觉眨眼。


所以我将睡眠(200)更改为睡眠(2000),仍然没有视觉眨眼。


所以我尝试添加一个Application.DoEvents,以便应用程序

有机会重新绘制屏幕。但当我尝试添加

Imports System.Windows.Forms时对于DoEvents,IDE说

System.Windows.Forms不包含任何公共成员或者不能找到



显然,DoEvents不能在WPF应用程序中使用,因为它不是Windows窗体的




好​​的,那么如何让WPF在视觉上眨眼呢?

中的一些文本字段响应按钮按下?

如何替换WPF应用程序中的DoEvents功能?

I have a WPF application in VB in VSTS 2008 RTM. I am trying to
"blink" (momentarily clear) a field of data if the data is reloaded
from the database to give the user some visual indication of the LOAD
operation.

So on the LOAD button I clear the text fields, do
mainCanvas.UpdateLayout( ), and the reload the text field from the
database. But the text fields are not cleared long enough to see them
blink.

So I add a Thread.Sleep(200) before reloading the text fields. Still
no visual blink.

So I change the Sleep(200) to Sleep(2000), Still no visual blink.

So I attempt to add an Application.DoEvents so that the application
gets a chance to repaint the screen. But when I attempt to add the
"Imports System.Windows.Forms" for the DoEvents, the IDE says
"System.Windows.Forms doesn''t contain any public member(s) or cannot
be found."

Apparently DoEvents can not be used in a WPF application because it is
not a Windows Forms.

OK, so how do I get WPF to visually "blink" some text fields in
response to a button push?
How do I replace the DoEvents functionality in a WPF application?

推荐答案

2008-03-18,Don< db ******* @ gmail.comwrote:
On 2008-03-18, Don <db*******@gmail.comwrote:

我有VSTS 2008 RTM中VB中的WPF应用程序。我正试图

眨眼 (暂时清除)数据字段,如果数据重新加载

从数据库中给用户一些视觉指示LOAD

操作。


所以在LOAD按钮上我清除文本字段,执行

mainCanvas.UpdateLayout(),然后从

数据库重新加载文本字段。但文本字段的清除时间不足以查看它们

闪烁。


所以我在重新加载文本字段之前添加一个Thread.Sleep(200)。还是

没有视觉眨眼。


所以我将睡眠(200)更改为睡眠(2000),仍然没有视觉眨眼。


所以我尝试添加一个Application.DoEvents,以便应用程序

有机会重新绘制屏幕。但当我尝试添加

Imports System.Windows.Forms时对于DoEvents,IDE说

System.Windows.Forms不包含任何公共成员或者不能找到



显然,DoEvents不能在WPF应用程序中使用,因为它不是Windows窗体的




好​​的,那么如何让WPF在视觉上眨眼呢?

中的一些文本字段响应按钮按下?

如何替换WPF应用程序中的DoEvents功能?
I have a WPF application in VB in VSTS 2008 RTM. I am trying to
"blink" (momentarily clear) a field of data if the data is reloaded
from the database to give the user some visual indication of the LOAD
operation.

So on the LOAD button I clear the text fields, do
mainCanvas.UpdateLayout( ), and the reload the text field from the
database. But the text fields are not cleared long enough to see them
blink.

So I add a Thread.Sleep(200) before reloading the text fields. Still
no visual blink.

So I change the Sleep(200) to Sleep(2000), Still no visual blink.

So I attempt to add an Application.DoEvents so that the application
gets a chance to repaint the screen. But when I attempt to add the
"Imports System.Windows.Forms" for the DoEvents, the IDE says
"System.Windows.Forms doesn''t contain any public member(s) or cannot
be found."

Apparently DoEvents can not be used in a WPF application because it is
not a Windows Forms.

OK, so how do I get WPF to visually "blink" some text fields in
response to a button push?
How do I replace the DoEvents functionality in a WPF application?



您是在引用System.Windows.Forms.dll吗?


-

Tom Shelton

Are you referencing System.Windows.Forms.dll?

--
Tom Shelton


3月18日,12:16 * pm,Tom Shelton

< tom_shel ... @ YOUKNOWTHEDRILLcomcast.netwrote:
On Mar 18, 12:16*pm, Tom Shelton
<tom_shel...@YOUKNOWTHEDRILLcomcast.netwrote:

2008-03-18,Don< dbaech ... @ gmail.comwrote:


On 2008-03-18, Don <dbaech...@gmail.comwrote:



我在VB中的VSTS 2008 RTM中有一个WPF应用程序。我正试图

眨眼 (暂时清除)数据字段如果数据重新加载

从数据库中给用户一些可视指示LOAD

操作。
I have a WPF application in VB in VSTS 2008 RTM. I am trying to
"blink" (momentarily clear) a field of data if the data is reloaded
from the database to give the user some visual indication of the LOAD
operation.


所以在LOAD按钮上清除文本字段,执行

mainCanvas.UpdateLayout(),并重新加载来自

数据库的文本字段。但是文本字段的清除时间不足以看到它们

闪烁。
So on the LOAD button I clear the text fields, do
mainCanvas.UpdateLayout( ), and the reload the text field from the
database. But the text fields are not cleared long enough to see them
blink.


所以我在重新加载文本字段之前添加一个Thread.Sleep(200)。还是

没有视觉眨眼。
So I add a Thread.Sleep(200) before reloading the text fields. Still
no visual blink.


所以我将睡眠(200)更改为睡眠(2000),仍然没有视觉眨眼。
So I change the Sleep(200) to Sleep(2000), Still no visual blink.


所以我尝试添加一个Application.DoEvents,以便应用程序

有机会重新绘制屏幕。但当我尝试添加

Imports System.Windows.Forms时对于DoEvents,IDE说

System.Windows.Forms不包含任何公共成员或者不能找到

So I attempt to add an Application.DoEvents so that the application
gets a chance to repaint the screen. But when I attempt to add the
"Imports System.Windows.Forms" for the DoEvents, the IDE says
"System.Windows.Forms doesn''t contain any public member(s) or cannot
be found."


显然,DoEvents不能在WPF应用程序中使用,因为它不是Windows窗体的

Apparently DoEvents can not be used in a WPF application because it is
not a Windows Forms.


好​​的,那么如何让WPF在视觉上闪烁?

中的一些文本字段响应按钮按下?

如何替换WPF应用程序中的DoEvents功能?
OK, so how do I get WPF to visually "blink" some text fields in
response to a button push?
How do I replace the DoEvents functionality in a WPF application?



您是在引用System.Windows.Forms.dll吗?


-

Tom谢尔顿 - 隐藏引用的文字 -


- 显示引用的文字 -


Are you referencing System.Windows.Forms.dll?

--
Tom Shelton- Hide quoted text -

- Show quoted text -



System.Windows.Forms未列在可用命名空间

项目属性中的引用。

我认为不能在WPF

应用程序中引用System.Windows.Forms。 br />

System.Windows.Forms is not listed in the available Namespaces under
References in Project Properties.
I do not think that System.Windows.Forms can be referenced in a WPF
application.


显然DoEvents不能在WPF应用程序中使用,因为它是
Apparently DoEvents can not be used in a WPF application because it is

不是Windows窗体。
not a Windows Forms.


好​​的,那么如何让WPF在视觉上闪烁?

中的一些文本字段响应按钮按下?

如何替换WPF应用程序中的DoEvents功能?
OK, so how do I get WPF to visually "blink" some text fields in
response to a button push?
How do I replace the DoEvents functionality in a WPF application?



您可以尝试:

http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954! 411.entry


对WPF不熟悉但是你可以通过使用WPF

动画来做到这一点吗?


-

Patrice

You could try :
http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!411.entry

Not familiar yet with WPF but you could perhaps do that by using a WPF
animation ?

--
Patrice


这篇关于不能在WPF应用程序中使用DoEvents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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