private void MainPage_Loaded(object sender, RoutedEventArgs e) { DataService.Instance.Dispatcher = new DispatcherWrapper(Dispatcher); BackgroundContainer.Blur(20, 0).Start(); if (_isHost) { if (App.IsXbox()) { PlayPause.Focus(FocusState.Keyboard); } this.PointerMoved += MainPage_PointerMoved; this.KeyDown += MainPage_KeyDown; _playerService.PropertyChanged += _dataService_PropertyChanged; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(10); _timer.Tick += _timer_Tick; _timer.Start(); } else { AddButton.Focus(FocusState.Pointer); UserSongCollection.ItemsSource = (_viewModel as ClientViewModel).UserSongs; var t = (_viewModel as ClientViewModel).LoadUserSongs(); this.SizeChanged += MainPage_SizeChanged; } }
private void NameTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { AddButton.Focus(); PerformAdd(); } }
protected override void OnAppearing() { base.OnAppearing(); // To refresh the UI when on reappearing ToDoListView.ItemsSource = viewModel.ToDoList; // -it's just handy AddButton.Focus(); }
private async void BindListItemsListView() { try { List <ListItem> ListItems = DatabaseHelper.GetListItems(CurrentListId); DefaultViewModel["ListItems"] = ListItems; AddButton.Focus(FocusState.Programmatic); } catch (Exception ex) { MessageDialog md = new MessageDialog(ex.Message, "Critical Error!"); await md.ShowAsync(); } }
private void OnClosing(object sender, CancelEventArgs e) { if (Presenter.NeedsSave) { AddButton.Focus(); // this is needed if the user edited a textbox and didnt leave the textbox, the changed text is not automatically saved until the focus leaves the textbox string error = Presenter.Save(); if (error.Length > 0) { var result = MessageBox.Show("Error, do you want to close anyway?" + Environment.NewLine + Environment.NewLine + error, "Error", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.No); if (result == MessageBoxResult.No) { e.Cancel = true; } } } }