Solved

WPF Form won't refresh

Posted on 2011-09-19
2
315 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

19 Experts available now in Live!

Get 1:1 Help Now