|
-
December 13th, 2011, 11:58 AM
#1
Updating the current window on demand
I have a WPF control TBStatus that is a TextBlock, with a hidden 'Please Wait...'.
What's the best way to actually update the screen after each delay? It waits the 10 seconds and puts up the control. I tried a Dispatcher and same thing. What's the trick?
TBStatus.Foreground = Brushes.Red;
for (i = 0; i < 5; i++)
{
TBStatus.Visibility = Visibility.Visible;
Thread.Sleep(1000);
TBStatus.Visibility = Visibility.Hidden;
Thread.Sleep(1000);
}
TBStatus.Visibility = Visibility.Visible;
-
December 13th, 2011, 09:10 PM
#2
Re: Updating the current window on demand
I typically use a refresh if I want something to update right away especially if the next line(s) would put it to sleep or are going to be busy processing data. I assume that is still an option in WPF?
Always use [code][/code] tags when posting code.
-
December 13th, 2011, 10:27 PM
#3
Re: Updating the current window on demand
Set your control to visibility collapsed:
Code:
mycontrol.Visibility = Visibility.Collapsed;
then use a story board. after it completes use an event handler and set the visibility to visible:
Code:
private void storyboard1_complteted(sender event args e)
{
mycontrol.Visibility = Visibility.Visible;
}
-
December 14th, 2011, 09:05 AM
#4
Re: Updating the current window on demand
There is no Refresh option in WPF.
Just setting the Visibility doesn't work. It waits until the 10 seconds are completely up before executing.
I think a Dispatcher method is almost the only way to get it working, but haven't totally got it yet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|