Results 1 to 4 of 4

Thread: Dialog Reuse?

  1. #1
    Addicted Member
    Join Date
    Jun 08
    Posts
    159

    Dialog Reuse?

    Hi All,

    I have a form that runs a foreach on a list. And during this I want each item in the list to show a dialog form (while running a background worker to run some changes). The problem is that I get the following error.

    Cannot set Visibility or call Show or ShowDialog after window has closed.

    What is the best method to get around this error? The dialog is basically a continuous progressbar that has text updated based on the background work being done. I want this because each item in the list will pace a value to the progressbar dialog form.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,763

    Re: Dialog Reuse?

    Show us the code you're using.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,763

    Re: Dialog Reuse?

    Hmmm... just did a quick test and apparently closing a WPF Window that was displayed using ShowDialog disposes it. The equivalent action in WinForms does not dispose the form, so that's a difference.

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 07
    Location
    England
    Posts
    7,534

    Re: Dialog Reuse?

    Quote Originally Posted by jmcilhinney View Post
    Hmmm... just did a quick test and apparently closing a WPF Window that was displayed using ShowDialog disposes it. The equivalent action in WinForms does not dispose the form, so that's a difference.
    Yeah that and also you cant actually dispose a WPF window - you just call Close and the garbage collector sorts it out. I think the fact that dialog forms dont stay open is a good thing because it never made sense to me for them to act any differently to when you show the form in non-dialog mode, but I dont like the fact that you cant manually dispose the window.

    As for the OP's original problem - you must be showing the window and then closing it and then trying to show it again or something... this is all you should be doing:
    Code:
    Dim SomeWindow As New MainWindow
    SomeWindow.ShowDialog()
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •