Search
Thursday, November 20, 2008 ..:: Blendblog.net ::.. Register  Login
 Bloggers Minimize

 Print   
 Sponsors Minimize

 Print   
 Users Online Minimize
Membership Membership:
Latest New User Latest: areel
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 15

People Online People Online:
Visitors Visitors: 0
Members Members: 0
Total Total: 0

Online Now Online Now:

 Print   
 Welcome to blendblog.net! Minimize

If you are a developer or designer who is creating cutting edge user interface experiences using Microsoft Expression Blend you've just found a great resource!  The purpose of this site is to share our experience with this brand new product.  As with any new piece of software there is a ton to discover.  Bugs will be revealed and workarounds discovered, hopefully this can be a resource to share in the discovery process!

While this site will focus largely on Expression Blend, it will also encompass WPF, Visual Studio, Silverlight, and other .net 3.5 technologies as they relate to the creation of great software.

Please login using your Microsoft LiveID or register a new account.  Doing so will let you comment on any of the blog entries on the site.  We look forward to helping you in your endeavors as well as you helping others in theirs!  We'd love to have more bloggers on our site...if you are interested please register and contact us!


 Print   
 Frustrating situation with textblock .text rendering Minimize
Location: BlogsSean Cullinan    
Posted by: Sean Cullinan 8/19/2008 2:05 PM

Grrrr!!!  This was one of the most frustrating issues I've encountered in WPF.  Unlike Winforms where you can always call a .refresh or .invalidate method on a control, no similar functionality exists in WPF.  Here's the scenario that caused my problem.  I had a splash screen that sets up some things in my applicatoin.  The last thing it does is declare a new instance of my main form and then show it.  The "new" method of my form takes about 3 seconds to run.  Prior to the statement creating the new form we change a status textblock on our splash screen to say "Building User Interface..."  Unfortunately, no matter what I did, I could NOT get this visual representation of the text to actually display before the new instance of our main form (which locks the UI and takes 3 seconds) began.  I tried playing with the  InvalidateVisual, UpdateLayout, InvalidateProperty methods on the textblock, the splash form, etc. withno luck.  Basically what I needed was a "DoEvents" type of statement.  I ended up doing this withe following code:

Dim datNow As DateTime = Now
While Now.Subtract(datNow).TotalMilliseconds < 100
    Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, New ThreadStart(AddressOf doNothing)) ' wait for 100 ms to update textbox...STUPID STUPID STUPID
End While

By allowing it to "chill" for 100 milliseconds it lets the UI render the new text on the textblock control.

I do not like this solution, it is a kludge and there HAS to be a better way to force the visual update of a control.  I can't spend any more time on such a menial task.  If anyone has any suggestions they'd be much appreciated!

Sean

Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel 

  
 Search Minimize

 Print   
 Archive Minimize

 Print   
 Blendblog Survey Minimize
Our next client application will be written using:




Submit Survey  View Results

 Print   
Copyright 2008 by blendblog.net   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2008 by DotNetNuke Corporation