Open Jimex opened 2 years ago
Hey @Jimex, initially, such functionality is implemented, but does not work properly yet.
Hey @Jimex, initially, such functionality is implemented, but does not work properly yet.
https://github.com/lepoco/wpfui/blob/bece9fb2815ca8fe4bb66fb70454d0f10d8f40b7/src/WPFUI/Controls/TitleBar.cs#L369 Yea I have tried this, but when I called this method from my code, the window still closed though.
private void TitleBar_OnCloseClicked(object sender, RoutedEventArgs e) { MinimizeWindow(true); e.Handled = true; }
Hi @Jimex, the MinimizeWindow()
method is working. It's just that the click event is also handled by TemplateButton_OnClick
https://github.com/lepoco/wpfui/blob/1ffa8c2466ee107215d341310afe17e4a3a97791/src/Wpf.Ui/Controls/TitleBar.cs#L616-L618
@pomianowski I would suggest to add a new property like IsCloseDefaultActionDisabled
and skip the CloseWindow()
when true. If that's ok, I can work on this.
RaiseEvent(new RoutedEventArgs(CloseClickedEvent, this));
if(!IsCloseDefaultActionDisabled) CloseWindow();
Hey, Are there any updates on this or is there a workaround to control wheter the window should close or just minimize to tray?
Edit: I found a workaround, this will only close the window when shift is pressed. If shift is not pressed, it will minimize the window to the tray
private void UiWindow_Closing(object sender, CancelEventArgs e)
{
if (Keyboard.GetKeyStates(Key.LeftShift) == KeyStates.Down)
{
Application.Current.Shutdown();
return;
}
e.Cancel = true;
Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
WindowState = WindowState.Minimized;
Hide();
}
<ui:UiWindow
....
Closing="UiWindow_Closing"
....>
</ui:UiWindow>
Can we have a function that minimizes the window to the tray after clicking the close icon?
Thank you.