0

i'm using a listview to display multiple items to the user. Now I want that the user has the ability to open an detail window with an double click. This works fine but when the window is opened it's immediatly pushed to the background.

I tried several things with the window state etc. the result was in every situation terrible(window is pushed to background or the window is a permanent overlay). The only solution that works relative well is that I change the DoubleClick Event in a MouseLeftButtonUp Event. When a user now click an item the window are in the foreground.

This is my code from the controller class:

public void ShowDetails(object details)
{
    Details detailWindow = new Details(this, Config.GetCultureInformation());
    detailWindow.LoadData(details);
    detailWindow.Show();
}

This my code from the UI Class

private void listViewItem_MouseClick(object sender, MouseButtonEventArgs e)
{
    ListViewItem item = sender as ListViewItem;
    AppControl.ShowDetails(item.Content);
}
Facundo La Rocca
  • 3,786
  • 2
  • 25
  • 47
mario0391
  • 5
  • 2

2 Answers2

0

You should show it as modal.

public void ShowDetails(object details)
{
    Details detailWindow = new Details(this, Config.GetCultureInformation());
    detailWindow.LoadData(details);
    detailWindow.ShowDialog(); //Instead of detailWindow.Show();
}

If you want to keep your main window without freeze use detailWindow.BringToFront() or detailWindow.TopMost = true, take a loot at this other post

Source here.

Community
  • 1
  • 1
Facundo La Rocca
  • 3,786
  • 2
  • 25
  • 47
  • Thanks for this quick solution. But this is not the behaviour that I want from my app. Now the main app is frozen when the details window appear. I want that the user has the possibility to interact with the main app and open multiple detail windows. – mario0391 Dec 30 '16 at 13:31
  • I've edited my answer with some other ways to manage it. Let me know if it works. – Facundo La Rocca Dec 30 '16 at 13:34
0

Ok. Thank you for your help and with Topmost I find I way to create a solution that suits for me.

In the constructor of my window I set topmost to true and in the Window is Loaded Event I set topmost to false. My Window is prominent in the foreground but the user can go out of it and can handle things in the main app.

mario0391
  • 5
  • 2