0

I have a WPF Application consisting of a MainWindow which also has a regular button inside. Bound to the button click event I am loading a serialized object via OpenFileDialog:

private void LoadNetwork_Click(object sender, RoutedEventArgs e)
{
    var openDialog = new OpenFileDialog { Multiselect = false };
    var result = openDialog.ShowDialog();
    if (result)
    {
        string file = openDialog.FileName;
        try
        {
             _network= new SimplifiedNetwork(file, 1);
             MessageBox.Show("Loaded OK");
        }
        catch (Exception)
        {
             MessageBox.Show("Load error");
        }
    }
}

After this method gets executed the UI doesn't update anymore. And when I say nothing, I mean not even the hover effects on the buttons in the Window work (not to mention updating labels via code behind, property changed events, begin invokes etc.), it's like it's frozen (but still responsive to clicks).

I thought it was something I did inside my routines, but simply reducing the method call to

private void LoadNetwork_Click(object sender, RoutedEventArgs e)
{
    var openDialog = new OpenFileDialog { Multiselect = false };
    var result = openDialog.ShowDialog();  
}

has the same result.

Clarification. -This occurs with after the Modal dialog is closed. -It also seems to manifest itself as soon as the UI loses focus for any reason (like minimize - restore, switch to another window). -This seems to occur only on my Windows 8.1 machine (put in an xp VM I have around, is OK).

Any ideas?

Sheridan
  • 68,826
  • 24
  • 143
  • 183
LuBa
  • 53
  • 1
  • 4
  • Yes, and the object gets loaded etc. Frozen is a poor choice, 'static' would actually be better. You know, when you hover over a button it changes it's color etc. after I call that method, the button doesn't react to my mouse cursor hovering. But I can still click it, and it will still perform the action bound to the click event. – LuBa Jan 25 '14 at 20:50
  • Are you saying that you cannot interact with your application whilst the file dialog is open? Is so, then this is by design. – MoonBoots89 Jan 25 '14 at 20:56
  • No afterwards, and interaction is partial (it responds to the commands, but doesn't visually update) – LuBa Jan 25 '14 at 21:45

1 Answers1

0

The OpenFileDialog is a modal dialog, it is intended that the window in the background is not responding when the dialog is open.

Here is more information and also a possible solution to your problem.

Community
  • 1
  • 1
thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110
  • Of course. But this still happens *after* I close the dialog. Actually, upon further inspection, my window stops updating after it loses focus (for eg minimize-> restore) – LuBa Jan 25 '14 at 21:03
  • it says nothing in your question about closing the dialog – thumbmunkeys Jan 25 '14 at 21:04