In my wpf application, when user click on menu, a new window will open, and user click an item in that window, another window will open. And when these all window minimized the user, and click any of the window in taskbar, I need to open these three window.
When user click on any of the window, I want to open the three window.
WindowState is a property on Window.
Subscribe to StateChanged event on the window.
this.StateChanged += MainWindow_StateChanged;
When this changes to Maximized for one of the windows, update the state for other windows as well.
this.WindowState = System.Windows.WindowState.Maximized;
Related
first picture -before click the combobox
As the first picture shows,I have a child window which has lots of comboboxs.
second picture -after click the combobox
Once I click the combobox and the combobox popup opened,then the child window will disappear, as the second picture shows.
In my opinion,the child window behaviors like come behind the mainwindow, like its zindex has changed.
Can anyboby has a clue,thanks a lot.
I have a wpf form which has one main window. when i click a button in main window it i will show a child window. I tried to restore the child window but couldn't. how to restore while it is minimized in system tray?
Something like this should work
if (this.MainWindow.WindowState == WindowState.Minimized)
{
this.MainWindow.WindowState = WindowState.Normal;
}
//bring window to front of all windows
this.MainWindow.Activate();
this.MainWindow should be the reference to the window you want to maximize or bring to normal state.
Regards,
I am using Application.Current.Activated to bring all windows to the front when any one is clicked. This is working great, but doesn't work when I have a modal dialog open using .ShowDialog()
Clicks on other windows of the application (besides the dialog) do not result in the application being activated. The default behavior is to do nothing. (The clicks appear to be entirely IGNORED!)
How can I make it so that when any window of the application is clicked, the open dialog is brought to the front? (The expected behavior based on how pretty much every application works)
YES: I did set the owner of the dialog to my MainWindow, and clicking on the main window produces the desired result, but clicking any other window does nothing.
Code:
Create a new WPF project and add two windows.
Then put a button on MainWindow.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Window1 foo = new Window1();
foo.Show();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Window2 modal = new Window2();
modal.Owner = this;
modal.ShowDialog();
}
}
To see what I'm talking about, click the button to open the modal dialog.
The desired behavior is what happens when MainWindow is clicked.
I want the same to happen when Window1 is clicked.
AFAIK, a modal dialog (which .ShowDialog() triggers) blocks all other windows thereby Activation events.
As per the MSDN:
When a Window class is instantiated, it is not visible by default. ShowDialog shows the window, disables all other windows in the application, and returns only when the window is closed. This type of window is known as a modal window.
http://msdn.microsoft.com/en-us/library/system.windows.window.showdialog(v=vs.110).aspx
This may be an ugly hack, but maybe you can accomplish what you need to by creating your modal window on a separate thread thereby letting your main application continue to process activation (and other) events? You would need a way to prevent 2 of that 2nd modal dialog from opening though.
I have an user control with elements inside. And this User control displays in popup window. I should hide popup window when user mouse leave from popup, so I should catch mouse leave from elements on user control. How to do it?
This issue regarding WPF window (XAML application)
I have a two windows one window getting launced from another window.
Both window get into maximized state when gets open
the child window which gets open has a grid on it and we have operation (double click on row click should close the window).
Problem is happening that when we double click on grid row it closes form correctly but if accidently mouse remains in the same position then some operation on previous window gets perform. if mouse point in different location then there is no problem.
I am not able to define this as event bubbling in WPF or routed events.
Could you please advise on this.
I think you should add:
e.Handled = true