CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    25

    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;

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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.

  3. #3
    Join Date
    May 2011
    Posts
    41

    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;
    }

  4. #4
    Join Date
    Mar 2004
    Posts
    25

    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
  •  





Click Here to Expand Forum to Full Width

Featured