SettingsWindowViewModel vm; //ViewModel

        public SettingsWindow(SettingsWindowViewModel viewMod)
        {
            InitializeComponent();
            vm = viewMod;
            vm.ReloadSettings();
            this.DataContext = vm;
        }
        private void Btn_Cancel(object sender, RoutedEventArgs e)
        {
            MainWindow win = (MainWindow)Application.Current.MainWindow;

            win.Show();
            this.Close();
            VM_settings.ReloadSettings();
        }
 /// <summary>
 /// The OK botton of the settings window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ok_Click(object sender, RoutedEventArgs e)
 {
     // if all the fields are not empty
     if (ServerIP.Text != "" && ServerPort.Text != "" && CommandPort.Text != "")
     {
         // update thee view model properties
         vm.FlightServerIP    = ServerIP.Text;
         vm.FlightInfoPort    = Int32.Parse(ServerPort.Text);
         vm.FlightCommandPort = Int32.Parse(CommandPort.Text);
         vm.SaveSettings();
         vm.ReloadSettings();
     }
     Close(); // close the window
 }