private SfTimePicker CreateNewTimePicker() { ExercisesTime currentExercises = (ExercisesTime)exercises; timePicker = new SfTimePicker() { PickerMode = PickerMode.Default, ShowHeader = false, EnableLooping = true, IsOpen = true, HeightRequest = 200, WidthRequest = 200, Time = new TimeSpan(currentExercises.Time.Hours, currentExercises.Time.Minutes, currentExercises.Time.Seconds) }; timePicker.TimeSelected += TimePicker_TimeSelected; return(timePicker); }
public static bool TryValueTimeSpan(this SfTimePicker control, out TimeSpan value) { value = default(TimeSpan); if (control.Value is TimeSpan newTimeSpan) { value = newTimeSpan; } else if (control.Value is DateTime newDateTime) { value = newDateTime.TimeOfDay; } else if (control.Value is null) { return(false); } else { throw new Exception("Unknown value type"); } return(true); }
/// <summary> /// This is a property changed util. /// </summary> /// <param name="dependencyObject"></param> /// <param name="eventArgs"></param> public static void PropertyChangedCb(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs) { // dry : the change is handled by the PasswordBox properties as well. if (dependencyObject is PasswordBox) { return; } if (dependencyObject is PercentTextBox) { PercentTextBox box = dependencyObject as PercentTextBox; box.LostFocus += Box_LostFocus1; return; } if (dependencyObject is SfDataGrid currentDataGrid) { // currentDataGrid.CurrentCellEndEdit += CurrentDataGrid_CurrentCellEndEdit; currentDataGrid.RecordDeleted += CurrentDataGrid_RecordDeleted; currentDataGrid.AddNewRowInitiating += CurrentDataGrid_AddNewRowInitiating; currentDataGrid.RowValidated += CurrentDataGrid_RowValidated; currentDataGrid.PreviewKeyDown += CurrentDataGrid_PreviewKeyDown; } if (dependencyObject is DataArea) { var dataArea = dependencyObject as DataArea; dataArea.ItemChangedCommand = GetItemChangedCommand(dataArea); dataArea.DataSource = GetDataSource(dataArea); dataArea.DataSourcePath = GetDataSourcePath(dataArea); return; } if (dependencyObject is SfTimePicker) { SfTimePicker picker = dependencyObject as SfTimePicker; picker.ValueChanged += Picker_ValueChanged; } if (dependencyObject is DatePicker datePicker) { datePicker.SelectedDateChanged += SelectedDate_Changed; } if (dependencyObject is DataDatePicker) { DataDatePicker dataDatePicker = dependencyObject as DataDatePicker; dataDatePicker.DataDatePickerChanged += DataDatePicker_DataDatePickerChanged; return; } if (dependencyObject is TextBox) { TextBox box = dependencyObject as TextBox; box.TextChanged += TextBox_ChangedBehaviour; box.LostFocus += Box_LostFocus; return; } if (dependencyObject is DataFieldCheckBox) { DataFieldCheckBox checkBox = dependencyObject as DataFieldCheckBox; var path = ControlExt.GetDataSourcePath(checkBox); if (!string.IsNullOrEmpty(path)) { var tmp = ControlExt.GetDataSource(checkBox); if (tmp != null) { var propValue = ComponentUtils.GetPropValue(tmp, path); if (propValue is string) { byte value = Convert.ToByte(propValue); if (value > 0) { checkBox.IsChecked = true; } } else { checkBox.IsChecked = Convert.ToBoolean(propValue); } } } //checkBox.Checked += CheckBox_DataChecked; // checkBox.Unchecked += CheckBox_DataUnChecked; checkBox.DataFieldCheckBoxChanged += CheckBox_DataFieldCheckBoxChanged; return; } if (dependencyObject is CheckBox checkBox1) { checkBox1.Checked += CheckBox_Checked; checkBox1.Unchecked += CheckBox_Unchecked; checkBox1.Click += checkBox_Clicked; return; } if (dependencyObject is ComboBox comboBox) { // here we do the combox box. comboBox.SelectionChanged += ComboBox_SelectionChanged; } }