Example #1
0
        protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e)
        {
            LoopItemsPanel itemsPanel = e.Container as LoopItemsPanel;

            if (itemsPanel == null)
            {
                return;
            }

            PickerSelectorItem selectorItem = itemsPanel.GetMiddleItem();

            if (selectorItem == null)
            {
                return;
            }

            DateTimeWrapper dateTimeWrapper = selectorItem.DataContext as DateTimeWrapper;

            if (dateTimeWrapper == null)
            {
                return;
            }

            this.Value = dateTimeWrapper.DateTime;
        }
Example #2
0
        /// <summary>
        /// On Manipulation, make focus on the good PickerSelector
        /// </summary>
        protected override void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
        {
            LoopItemsPanel itemsPanel = e.Container as LoopItemsPanel;

            if (itemsPanel == null)
            {
                return;
            }

            RefreshRect();
            // fake Position to get the correct PickerSelector
            Point position = new Point(itemsPanel.ParentDatePickerSelector.RectPosition.X + 1,
                                       itemsPanel.ParentDatePickerSelector.RectPosition.Y + 1);

            FocusPickerSelector(position, FocusSourceType.Manipulation);
        }
        /// <summary>
        /// Prepares the specified element to display the specified item.
        /// </summary>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            itemsPanel = this.GetVisualDescendent <LoopItemsPanel>();

            // get the item
            PickerSelectorItem loopListItem    = element as PickerSelectorItem;
            DateTimeWrapper    dateTimeWrapper = item as DateTimeWrapper;

            if (loopListItem == null || dateTimeWrapper == null)
            {
                return;
            }

            if (this.ItemTemplate == null)
            {
                return;
            }

            // load data templated
            var contentElement = this.ItemTemplate.LoadContent() as FrameworkElement;

            if (contentElement == null)
            {
                return;
            }
            // attach DataContext and Context to the item
            loopListItem.Style       = ItemContainerStyle;
            loopListItem.DataContext = item;
            loopListItem.Content     = contentElement;
            loopListItem.IsSelected  = dateTimeWrapper == this.SelectedItem;
            loopListItem.IsFocused   = this.IsFocused;
        }