private void NewPacient_OnClick(object sender, RoutedEventArgs e) { var viewModel = DataContext as MammaViewModel; if (viewModel != null && viewModel.SaveCommand.CanExecute(null)) { var dialogResult = MessageBox.Show("Есть несохраненные изменения. Сохранить их?", "УЗД молочной железы", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes); switch (dialogResult) { case MessageBoxResult.Yes: viewModel.SaveCommand.Execute(null); break; case MessageBoxResult.Cancel: return; } } else { var dialogResult = MessageBox.Show("Вы уверны, что хотите начать прием нового пациента?", "УЗД молочной железы", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (dialogResult == MessageBoxResult.No) { return; } } DataContext = ContainerFactory.Get <MammaViewModel>(); MainScrollViewer.ScrollToTop(); }
public MainWindow() { InitializeComponent(); MainVm = (MainVM)this.DataContext; MainVm.SetPassFunc(() => PasswordBox.Password, () => PasswordBox.Password = string.Empty); MainVm.ContentChanged += () => MainScrollViewer.ScrollToTop(); }
// Adds the course buttons. public void addButtons(SortedList <String, CourseItem> courseList) { // Electrical has 30 4th year courses!!! Grid fadeIn = fadePanels[currrentPanel++ % 2]; Grid fadeOut = fadePanels[currrentPanel % 2]; StackPanel[] cols = { fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Clear old courses. foreach (StackPanel c in cols) { c.Children.Clear(); } //cols = new StackPanel[]{ fadeIn.Children[0] as StackPanel, fadeIn.Children[1] as StackPanel, fadeIn.Children[2] as StackPanel, fadeIn.Children[3] as StackPanel }; // Actually add courses. int currentCol = 0; foreach (KeyValuePair <String, CourseItem> kvp in courseList) { CourseButton button = new CourseButton() { CourseTitle = kvp.Value.Name, CourseCode = kvp.Key, CourseItem = kvp.Value }; button.PreviewTouchDown += ClickCourse; button.PreviewMouseDown += ClickCourse; cols[currentCol].Children.Add(button); currentCol = (currentCol + 1) % cols.Length; // Add courses to lines alternatively (eg: line 1, 2, 1, 2 etc). //panelLines[line++ % panelLines.Count()].Children.Add(button); // Make button the colour of that specialisation. setButtonColour(button); } fadeIn.Opacity = 0; Storyboard sb1 = (Storyboard)Resources["FadeOut"]; Storyboard sb2 = (Storyboard)Resources["FadeIn"]; sb1.Completed += FadeOut_Completed; sb1.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); sb2.SeekAlignedToLastTick(new TimeSpan(0, 0, 10)); MainScrollViewer.ScrollToTop(); sb1.Begin(fadeOut); sb2.Begin(fadeIn); }
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) { string activeFilter = ""; foreach (var i in FilterStrings) { if (SearchControl.Text == i + ":") { activeFilter = i; } } if (activeFilter == "") { foreach (UIElement i in MainStackPanel.Children) { if ((i as ISettingControl).Contains(SearchControl.Text)) { i.Visibility = Visibility.Visible; } else { i.Visibility = Visibility.Collapsed; } } FilterListBox.SelectedItem = null; } else { foreach (UIElement i in MainStackPanel.Children) { if ((i as ISettingControl).SettingBase.Filter == activeFilter) { i.Visibility = Visibility.Visible; } else { i.Visibility = Visibility.Collapsed; } } } MainScrollViewer.ScrollToTop(); }
private void FrameworkElement_OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { MainScrollViewer.ScrollToTop(); }