private static void SetText(DependencyObject d, DependencyPropertyChangedEventArgs e) { ContactControl control = d as ContactControl; if (control != null) { control.nameTextBlock.Text = (e.NewValue as Contact).Name; control.emailTextBlock.Text = (e.NewValue as Contact).Email; control.phoneTextBlock.Text = (e.NewValue as Contact).Phone; } }
private static void SetText(DependencyObject d, DependencyPropertyChangedEventArgs e) { ContactControl control = d as ContactControl; if (control != null) { control.textblockName.Text = (e.NewValue as Contact).Name; control.textblockEmail.Text = (e.NewValue as Contact).Email; control.textblockPhoneNumber.Text = (e.NewValue as Contact).PhoneNumber; } }
// The "Event handler" which sets our setText when the text is changed // d sets control as our Contact Control dependency object which will give us control of the textBlocks private static void SetText(DependencyObject d, DependencyPropertyChangedEventArgs e) { ContactControl control = d as ContactControl; if (control != null) { control.nameTextBlock.Text = (e.NewValue as ContactModel).Name; // Everytime the text is changed, the new value is assigned to Name control.emailTextBlock.Text = (e.NewValue as ContactModel).Email; control.phoneTextBlock.Text = (e.NewValue as ContactModel).Phone; } }
private static void SetText(DependencyObject d, DependencyPropertyChangedEventArgs e) { ContactControl control = d as ContactControl; if (control != null) { control.nameTextBlock.Text = (e.NewValue as Customer).Name; control.emailTextBlock.Text = (e.NewValue as Customer).Email; control.phoneTextBlock.Text = (e.NewValue as Customer).Phone; control.addressTextBlock.Text = (e.NewValue as Customer).Address; control.dateTextBlock.Text = "Last Service Date: " + (e.NewValue as Customer).DateLastTuned.ToShortDateString(); control.nextApptTextBlock.Text = "Next Scheduled Appt: " + (e.NewValue as Customer).NextApptDate.ToShortDateString() + " at " + (e.NewValue as Customer).NextApptTime; control.notesTextBlock.Text = "Notes: " + (e.NewValue as Customer).Notes; } }