Solved

WPF Form won't refresh

Posted on 2011-09-19
2
319 Views
Last Modified: 2012-05-12
Hello,

I have a sample WPF project which represents an issue that I am having.  

The main WPF window has a textbox that I have bound to a custom DependencyObject's (the TextboxText class inherits from DependencyObject) DependencyProperty named TextIt.  I have a command button that when clicked calls the TextIt's class' PrintIt() Method.  The PrintIt method has a for loop where the TextIt property is being updated and then put to sleep for a few milliseconds.  

My intent is to see the value, that the dependency property is changed to, in the WPF window each time the dependency property is updated from the PrintIt method.  Did I miss something? WpfTest.zip
0
Comment
Question by:modotx
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36562236
Try placing the DoEvents() method here:
http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcherframe.aspx

...into your loop:

        For i = 0 To 100
            TextIt = "Test" & i.ToString
            System.Threading.Thread.Sleep(500)
            DoEvents()
        Next
0
 

Author Comment

by:modotx
ID: 36563101
I wound up using the code supplied in the link since I wasn't wanting to have to include the VB.Net assembly as a reference.  Ty so much
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now