/// <summary> /// When focus is set, just set IsFocused on the itemsPanel /// </summary> private static void OnIsFocusedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null || (e.NewValue == e.OldValue)) { return; } PickerSelector pickerSelector = (PickerSelector)d; bool isFocused = (bool)e.NewValue; pickerSelector.UpdateIsFocusedItems(isFocused); }
/// <summary> /// Override of OnApplyTemplate /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); this.InitializationInProgress = true; primarySelector = GetTemplateChild(PrimarySelectorName) as PickerSelector; secondarySelector = GetTemplateChild(SecondarySelectorName) as PickerSelector; tertiarySelector = GetTemplateChild(TertiarySelectorName) as PickerSelector; // Create wrapper on current value var wrapper = new DateTimeWrapper(Value); // Init Selectors // Set Datasource if (primarySelector != null) { primarySelector.DatePicker = this; primarySelector.YearDataSource = new YearDataSource(); primarySelector.DataSourceType = DataSourceType.Year; primarySelector.CreateOrUpdateItems(wrapper.DateTime); } if (secondarySelector != null) { secondarySelector.DatePicker = this; secondarySelector.MonthDataSource = new MonthDataSource(); secondarySelector.DataSourceType = DataSourceType.Month; secondarySelector.CreateOrUpdateItems(wrapper.DateTime); } if (tertiarySelector != null) { tertiarySelector.DatePicker = this; tertiarySelector.DayDataSource = new DayDataSource(); tertiarySelector.DataSourceType = DataSourceType.Day; tertiarySelector.CreateOrUpdateItems(wrapper.DateTime); } this.ResetPickersOrder(); this.InitializationInProgress = false; }
/// <summary> /// On Tapped, make focus on the good PickerSelector /// </summary> protected override void OnTapped(TappedRoutedEventArgs e) { RefreshRect(); Point point = e.GetPosition(this); FocusPickerSelector(point, FocusSourceType.Tap); PickerSelector selector = null; if (primarySelector != null && point.X > primarySelector.RectPosition.X && point.X < (primarySelector.RectPosition.X + primarySelector.RectPosition.Width)) { selector = primarySelector; } if (secondarySelector != null && point.X > secondarySelector.RectPosition.X && point.X < (secondarySelector.RectPosition.X + secondarySelector.RectPosition.Width)) { selector = secondarySelector; } if (tertiarySelector != null && point.X > tertiarySelector.RectPosition.X && point.X < (tertiarySelector.RectPosition.X + tertiarySelector.RectPosition.Width)) { selector = tertiarySelector; } if (selector != null) { DateTimeWrapper dateTimeWrapper = selector.SelectedItem; if (dateTimeWrapper == null) { return; } this.Value = dateTimeWrapper.DateTime; } }