using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; using GalaSoft.MvvmLight; using SchoolSample.Common; namespace SchoolSample { /// <summary> /// Interaction logic for InstructorPage.xaml /// </summary> public partial class InstructorPage : Page { #region "Constructor" public InstructorPage() { InitializeComponent(); // register for BeginEditMessage AppMessages.BeginEditMessage.Register(this, OnBeginEditMessage); // register for EndEditMessage AppMessages.EndEditMessage.Register(this, OnEndEditMessage); // register for CancelEditMessage AppMessages.CancelEditMessage.Register(this, OnCancelEditMessage); if (!ViewModelBase.IsInDesignModeStatic) { // Use MEF To load the View Model DataContext = App.Container.GetExportedValue<ViewModelBase>( ViewModelTypes.InstructorPageViewModel); } // set up OneWayToSource binding from instructorValidationSummary // to CurrentInstructorHasErrors var binding = new Binding { Path = new PropertyPath("CurrentInstructorHasErrors"), Mode = BindingMode.OneWayToSource }; instructorValidationSummary.SetBinding(ValidationSummary.HasErrorsProperty, binding); } #endregion "Constructor" #region "BeginEditMessage" private void OnBeginEditMessage(string screenName) { switch (screenName) { case "Instructor": nameLabel.Foreground = new SolidColorBrush(Colors.Black); nameTextBox.IsEnabled = true; nameDescriptionViewer.Visibility = Visibility.Visible; hireDateLabel.Foreground = new SolidColorBrush(Colors.Black); hireDateDatePicker.IsEnabled = true; hireDateDescriptionViewer.Visibility = Visibility.Visible; salaryLabel.Foreground = new SolidColorBrush(Colors.Black); salaryTextBox.IsEnabled = true; salaryDescriptionViewer.Visibility = Visibility.Visible; editCommitInstructorButton.Content = "Commit"; break; } } #endregion "BeginEditMessage" #region "EndEditMessage" private void OnEndEditMessage(string screenName) { switch (screenName) { case "Instructor": nameLabel.Foreground = new SolidColorBrush(Colors.Gray); nameTextBox.IsEnabled = false; nameDescriptionViewer.Visibility = Visibility.Collapsed; hireDateLabel.Foreground = new SolidColorBrush(Colors.Gray); hireDateDatePicker.IsEnabled = false; hireDateDescriptionViewer.Visibility = Visibility.Collapsed; salaryLabel.Foreground = new SolidColorBrush(Colors.Gray); salaryTextBox.IsEnabled = false; salaryDescriptionViewer.Visibility = Visibility.Collapsed; editCommitInstructorButton.Content = "Edit"; break; } } #endregion "EndEditMessage" #region "CancelEditMessage" private void OnCancelEditMessage(string screenName) { switch (screenName) { case "Instructor": nameLabel.Foreground = new SolidColorBrush(Colors.Gray); nameTextBox.IsEnabled = false; nameDescriptionViewer.Visibility = Visibility.Collapsed; hireDateLabel.Foreground = new SolidColorBrush(Colors.Gray); hireDateDatePicker.IsEnabled = false; hireDateDescriptionViewer.Visibility = Visibility.Collapsed; salaryLabel.Foreground = new SolidColorBrush(Colors.Gray); salaryTextBox.IsEnabled = false; salaryDescriptionViewer.Visibility = Visibility.Collapsed; editCommitInstructorButton.Content = "Edit"; break; } } #endregion "CancelEditMessage" } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)