Posted 23 July 2020, 8:35 pm EST
Hi Mayur,
1) Yes, there is no such method for TimeEditor yet. However, I have raised an enhancement request for the same (TFS ID: 454790) and will inform you for any update.
However, as a workaround, you can validate the C1TimeEditor value as follows:
private void FinalizeTimeEditorEditing()
{
var maskedTextBox = timeEditor.Template.FindName("TextBox", timeEditor) as C1MaskedTextBox;
string[] formats = new string[] { "hh:mm:ss tt", "h:m:s tt", "hh:mm:ss", "h:m:s" };
if (!DateTime.TryParseExact(maskedTextBox.Text, formats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out DateTime time))
{
TimeSpan timeSpan = timeEditor.Value.Value;
maskedTextBox.Text = new DateTime().Add(timeSpan).ToLongTimeString();
}
else
{
timeEditor.Value = time.TimeOfDay;
}
}
Just in case, You can alternatively use the C1DateTimePicker (which provides FinalizeEditing() method) and specify to show only DatePicker, TimeEditor or both by using its EditMode property.
For example:
// For showing only DatePicker
dateTimePicker.EditMode = C1DateTimePickerEditMode.Date
// For showing only TimeEditor
dateTimePicker.EditMode = C1DateTimePickerEditMode.Time
2) Please use the condition as follows:
if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F)
{
datePicker.FinalizeEditing();
}
Regards,
Basant