private void AddHourFlyout_Click(object sender, RoutedEventArgs e) { FrameworkElement senderElement = sender as FrameworkElement; Day day = (Day)senderElement.DataContext; TimePickerFlyout picker = new TimePickerFlyout(); picker.ShowAt(senderElement); picker.TimePicked += async (s, a) => { DateTime date = day.Check.DateTime.Date.AddTicks(a.NewTime.Ticks); await Historic.Historic.AddAsync(new TTCheck { DateTime = date, UserName = SecurityService.getCredential().Item1 }); }; }
private void DoDatePickerFlyout_DatePicked(DatePickerFlyout sender, DatePickedEventArgs args) { var dateTimePicker = sender; var secondTimepicker = new TimePickerFlyout(); secondTimepicker.Placement = FlyoutPlacementMode.Full; secondTimepicker.ShowAt(OdButton); dateDo = new DateTime(dateTimePicker.Date.Year, dateTimePicker.Date.Month, dateTimePicker.Date.Day, 0, 0, 0); secondTimepicker.TimePicked += SecondTimepicker_TimePicked; }
void OnTimeFly(object sender, TappedRoutedEventArgs e) { if (ReadOnlyBinding) { return; } // 时间选择器 TimePickerFlyout tf = new TimePickerFlyout(); tf.Time = Value - Value.Date; tf.TimePicked += (s, args) => Value = Value.Date + args.NewTime; tf.ShowAt(_grid); }
private void AddHourFlyout_Click(object sender, RoutedEventArgs e) { FrameworkElement senderElement = sender as FrameworkElement; Day day = (Day)senderElement.DataContext; TimePickerFlyout picker = new TimePickerFlyout(); picker.ShowAt(senderElement); picker.TimePicked += async(s, a) => { DateTime date = day.Check.DateTime.Date.AddTicks(a.NewTime.Ticks); await Historic.Historic.AddAsync(new TTCheck { DateTime = date, UserName = SecurityService.getCredential().Item1 }); }; }
internal override void OnElementFocusChangeRequested(object sender, VisualElement.FocusRequestArgs args) { base.OnElementFocusChangeRequested(sender, args); // Show a picker fly out on focus to match iOS and Android behavior var flyout = new TimePickerFlyout { Placement = FlyoutPlacementMode.Bottom, Time = Control.Time }; flyout.TimePicked += (p, e) => Control.Time = p.Time; if (!Element.IsVisible) { flyout.Placement = FlyoutPlacementMode.Full; } flyout.ShowAt(Control); }
void OnDateTimeFly(object sender, TappedRoutedEventArgs e) { if (ReadOnlyBinding) { return; } // uno无法给出相对位置 TextBlock tb = _grid.Children[0] as TextBlock; var pt = e.GetPosition(null); // 无文本内容时按Grid计算 MatrixTransform trans = string.IsNullOrEmpty(tb.Text) ? _grid.TransformToVisual(null) as MatrixTransform : tb.TransformToVisual(null) as MatrixTransform; if (trans == null) { return; } bool showDateFly = (pt.X <= trans.Matrix.OffsetX + tb.ActualWidth / 2 + 10) && !_dateInTail; if (showDateFly) { // 日期选择器 DatePickerFlyout fly = new DatePickerFlyout(); fly.Date = Value; fly.DatePicked += (s, args) => Value = args.NewDate.DateTime.Date + (Value - Value.Date); fly.ShowAt(_grid); } else { // 时间选择器 TimePickerFlyout tf = new TimePickerFlyout(); tf.Time = Value - Value.Date; tf.TimePicked += (s, args) => Value = Value.Date + args.NewTime; tf.ShowAt(_grid); } }
private void datePickerFlyout_DatePicked(DatePickerFlyout sender, DatePickedEventArgs args) { TimePickerFlyout timePickerFlyout = new TimePickerFlyout(); timePickerFlyout.TimePicked += timePickerFlyout_TimePicked; timePickerFlyout.ShowAt(Frame); addDate = args.NewDate; Debug.WriteLine(addDate.Date.ToString()); }