Search code examples
c#windows-phone-8

c# wp8 timepicker deactivation default eventhandler


I want to have in my application timepicker, which when pressed long set the current time. Setting the time works correctly (hold event), but it also opens the screen for entering the time (just as when I click on timepicker only). Is it possible to change this behavior? When clicked, I would like to open a screen to set the time as normal, but not when long pressed. Thanks for the reply.

Microsoft.Phone.Controls.TimePicker time = new TimePicker();
        time.FontSize = 18;
        time.Height = 50;
        time.Hold += time_Hold;

private void time_Hold(object sender, System.Windows.Input.GestureEventArgs e) { ((TimePicker)sender).Value = DateTime.Now;
}


Solution

  • There seems to be no easy way to accomplish this.

    You can find the source code of the TimePicker here: https://phone.codeplex.com/SourceControl/latest#Microsoft.Phone.Controls.Toolkit/DateTimePickers/TimePicker.cs

    Maybe subclassing this class and overriding DateTimePickerBase::OnApplyTemplate() could be a way to proceed...