public void StartViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     //
 }
 public void CompleteViewChangeFrom(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     this.IsActiveView = false;
 }
 public void CompleteViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     this.IsActiveView = true;
 }
Beispiel #4
0
 /// <summary>
 /// Forces content in the view to scroll until the item specified by SemanticZoomLocation is visible. Also focuses that item if found.
 /// </summary>
 /// <param name="item">The item in the view to scroll to.</param>
 public void MakeVisible(SemanticZoomLocation item)
 {
     //if (null != item.Item && !IsNavigating)
     //this.SelectedItem = item.Item;
 }
Beispiel #5
0
#pragma warning disable 1998 // considered for removal
        async void ScrollTo(object group, object item, ScrollToPosition toPosition, bool shouldAnimate, bool includeGroup = false, bool previouslyFailed = false)
#pragma warning restore 1998
        {
            ScrollViewer viewer = GetScrollViewer();

            if (viewer == null)
            {
                RoutedEventHandler loadedHandler = null;
                loadedHandler = async(o, e) =>
                {
                    List.Loaded -= loadedHandler;

                    // Here we try to avoid an exception, see explanation at bottom
                    await Dispatcher.RunIdleAsync(args => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup); });
                };
                List.Loaded += loadedHandler;
                return;
            }
            var templatedItems        = TemplatedItemsView.TemplatedItems;
            Tuple <int, int> location = templatedItems.GetGroupAndIndexOfItem(group, item);

            if (location.Item1 == -1 || location.Item2 == -1)
            {
                return;
            }

            object[] t = templatedItems.GetGroup(location.Item1).ItemsSource.Cast <object>().ToArray();
            object   c = t[location.Item2];

            // scroll to desired item with animation
            if (shouldAnimate && ScrollToItemWithAnimation(viewer, c))
            {
                return;
            }

            double viewportHeight = viewer.ViewportHeight;

            var semanticLocation = new SemanticZoomLocation {
                Item = c
            };

            switch (toPosition)
            {
            case ScrollToPosition.Start:
            {
                List.ScrollIntoView(c, ScrollIntoViewAlignment.Leading);
                return;
            }

            case ScrollToPosition.MakeVisible:
            {
                List.ScrollIntoView(c, ScrollIntoViewAlignment.Default);
                return;
            }

            case ScrollToPosition.End:
            case ScrollToPosition.Center:
            {
                var content = (FrameworkElement)List.ItemTemplate.LoadContent();
                content.DataContext = c;
                content.Measure(new Windows.Foundation.Size(viewer.ActualWidth, double.PositiveInfinity));

                double tHeight = content.DesiredSize.Height;

                if (toPosition == ScrollToPosition.Center)
                {
                    semanticLocation.Bounds = new Rect(0, viewportHeight / 2 - tHeight / 2, 0, 0);
                }
                else
                {
                    semanticLocation.Bounds = new Rect(0, viewportHeight - tHeight, 0, 0);
                }

                break;
            }
            }

            // Waiting for loaded doesn't seem to be enough anymore; the ScrollViewer does not appear until after Loaded.
            // Even if the ScrollViewer is present, an invoke at low priority fails (E_FAIL) presumably because the items are
            // still loading. An invoke at idle sometimes work, but isn't reliable enough, so we'll just have to commit
            // treason and use a blanket catch for the E_FAIL and try again.
            try
            {
                List.MakeVisible(semanticLocation);
            }
            catch (Exception)
            {
                if (previouslyFailed)
                {
                    return;
                }

                Task.Delay(1).ContinueWith(ct => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup, true); }, TaskScheduler.FromCurrentSynchronizationContext()).WatchForError();
            }
        }
 /// <summary>
 /// Initializes item-wise operations related to a view change when the source view is a different view and the pending destination view is the implementing view.
 /// </summary>
 /// <param name="source">The view item as represented in the source view.</param>
 /// <param name="destination">The view item as represented in the destination view.</param>
 public void StartViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     destination.Item = source.Item;
 }
Beispiel #7
0
 /// <summary>
 /// Completes item-wise operations related to a view change when the implementing view is the destination view and the source view is a potentially different implementing view.
 /// </summary>
 /// <param name="source">The view item as represented in the source view.</param>
 /// <param name="destination">The view item as represented in the destination view.</param>
 public void CompleteViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
 }
 public void MakeVisible(SemanticZoomLocation item)
 {
 }
 public void StartViewChangeFrom(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     source.Item = this.dataGrid.GetDataView().Items.OfType <IDataGroup>().Select(c => c.Key);
 }
 /// <summary>
 /// Completes item-wise operations related to a view change
 /// when the implementing view is the destination view and the source view is a potentially
 /// different implementing view.
 /// </summary>
 /// <param name="source">The view item as represented in the source view.</param>
 /// <param name="destination">The view item as represented in the destination view.</param>
 public void CompleteViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     SelectedItem = source.Item;
     Focus(Windows.UI.Xaml.FocusState.Programmatic);
 }
 public void CompleteViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     // throw new NotImplementedException();
 }
 /// <summary>
 /// Initializes item-wise operations related to a view change
 /// when the implementing view is the source view and the pending
 /// destination view is a potentially different implementing view.
 /// </summary>
 /// <param name="source">The view item as represented in the source view.</param>
 /// <param name="destination">The view item as represented in the destination view.</param>
 public void StartViewChangeFrom(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     destination.Item = SelectedItem;
 }
Beispiel #13
0
 public void CompleteViewChangeTo(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     Focus((FocusState)3);
 }
Beispiel #14
0
 public void StartViewChangeFrom(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     // Set the destination item to the currently selected item
     destination.Item = this.SelectedItem;
 }
 public void StartViewChangeFrom(SemanticZoomLocation source, SemanticZoomLocation destination)
 {
     //throw new NotImplementedException();
 }
 public void MakeVisible(SemanticZoomLocation item)
 {
     //throw new NotImplementedException();
 }