private void connectButton_Click(object sender, RoutedEventArgs e) { if (!vm.VM_Connected) { string ip = ipTextBox.Text; int port = Int32.Parse(portTextBox.Text); if ((ip != "localhost" && ip != "127.0.0.1") || port != 5402) { errorWindow.Content = "Invalid Port or IP ! please re-insert correct credentials"; errorArea.Background = Brushes.Red; } else { model.setClient(new MyTelnetClient()); vm.connect(ip, port); SteerVM steerVM = new SteerVM(this.model); //MapVM mapVM = new MapVM(this.model); vm = new FlightGearViewModel(this.model); //mapUC.DataContext = mapVM; steerUC.DataContext = steerVM; DataContext = vm; } } else { errorWindow.Content = "Exception: you are already connected"; errorArea.Background = Brushes.Red; } }
public steer() { InitializeComponent(); this.Loaded += (s, e) => { steerVM = (SteerVM)DataContext; }; }