I'm creating a little WPF app in VS2013Express
and I've come across a little problem.
You see, there are three windows, MainWindow
, LatAndLongDialog
, TimeCitiesDialog
.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GlobalTime_ELITE_for_WPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
UserDescText.Content =
"Select a TimeCity or enter the latitude and longitude in \n" +
"to view the World Time there. Or, select another one of the\n" +
"options below to do that. Go to Help by clicking on the link\n" +
"on the upper-right corner of the window to view everything you\n" +
"can do.";
this.Closed += CloseOff;
}
private void OpenTimeCitiesDialog(Object Sender, EventArgs E)
{
TimeCitiesDialog ObjectReference = new TimeCitiesDialog();
ObjectReference.Show();
}
private void OpenLatAndLongDialog(Object Sender, EventArgs E)
{
LatAndLongDialog ObjectReference = new LatAndLongDialog();
ObjectReference.Show();
}
private void CloseOff(Object Sender, EventArgs E)
{
this.Close();
TimeCitiesDialog tcdor = new TimeCitiesDialog();
LatAndLongDialog laldor = new LatAndLongDialog();
}
}
}
How can I close them all? Please help!
It can be tempting to slam the doors and hope the cool air builds up in the areas where you want it, but the fact is that modern air conditioning units are designed as whole-house systems. So when you shut that door, you're only making it much harder for your system to cool your home.
Should you keep your windows shut during hot weather? Generally speaking, you should open your windows if it's cooler outside than in. There's no 'set rule' for keeping windows open or closed during a bout of hot weather.
Outdoor Temperature Opening the windows simply lets cool air escape and hot air to enter, resulting in hotter interiors. Before deciding to open all your windows at home during hot weather, grab a thermometer, and check if it's hotter outside the house. If it's cooler indoors, just close your windows.
Even opening a window a crack is going to interfere with your air conditioner's efficiency. This creates vacuum pressure that will force the cool air out of your window and siphon air from other gaps in your home.
The proper way to shutdown a WPF app is to use Application.Current.Shutdown()
. This will close all open Window
s, raise some events so that cleanup code can be run, and it can't be canceled.
Environment.Exit()
terminates the application immediately even if other threads are executing.
You should also consider setting the Owner
on non-main Window
s. The behavior will likely be more like what you would expect in regards to Z-order, minimizing, and maximizing. As an added bonus, the owned windows will automatically close when the owner Window
closes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With