public override void OnApplyTemplate()
{
//get the hours textbox and hook the events to it
hours = GetTemplateChild("PART_Hours") as TextBox;
hours.PreviewTextInput += HoursTextChanged;
hours.KeyUp += HoursKeyUp;
hours.GotFocus += TextGotFocus;
hours.GotMouseCapture += TextGotFocus;
//get the minutes textbox and hook the events to it
minutes = GetTemplateChild("PART_Minutes") as TextBox;
minutes.PreviewTextInput += MinutesTextChanged;
minutes.KeyUp += MinutesKeyUp;
minutes.GotFocus += TextGotFocus;
minutes.GotMouseCapture += TextGotFocus;
//get the seconds textbox and hook the events to it
seconds = GetTemplateChild("PART_Seconds") as TextBox;
seconds.PreviewTextInput += SecondsTextChanged;
seconds.KeyUp += SecondsKeyUp;
seconds.GotFocus += TextGotFocus;
seconds.GotMouseCapture += TextGotFocus;
//Get the increase button and hook to the click event
ButtonBase increaseButton = GetTemplateChild("PART_IncreaseTime") as ButtonBase;
increaseButton.Click += IncreaseTime;
//Get the decrease button and hook to the click event
ButtonBase decrementButton = GetTemplateChild("PART_DecrementTime") as ButtonBase;
decrementButton.Click += DecrementTime;
}