private void ItemsGridView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var item = e.AddedItems.OfType <福利>().FirstOrDefault(); if (item != null) { ItemsGridView.ScrollIntoView(item); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.NavigationMode == NavigationMode.Back) { ItemsGridView.Loaded += async(o_, e_) => { var connectedAnimation = ConnectedAnimationService .GetForCurrentView() .GetAnimation("BorderDest"); if (connectedAnimation != null) { var item = ItemsGridView.Items[s_persistedItemIndex]; ItemsGridView.ScrollIntoView(item); await ItemsGridView.TryStartConnectedAnimationAsync( connectedAnimation, item, "BorderSource" ); } }; } }
private async void ItemsGridView_Loaded(object sender, RoutedEventArgs e) { if (ConnectedAnimationData.AnimationIsEnabled) { if (_navigatedUri != null) { //récupération de l'animation var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("Image"); if (animation != null) { var item = ViewModel.Items.First(compare => compare.ImageUrl == _navigatedUri); //on scroll vers l'item ItemsGridView.ScrollIntoView(item, ScrollIntoViewAlignment.Default); await Task.Yield(); var container = ItemsGridView.ContainerFromItem(item) as GridViewItem; if (container != null) { var root = (FrameworkElement)container.ContentTemplateRoot; var image = (Image)root.FindName("ImageItem"); image.Opacity = 1; //on lance l'animation animation.TryStart(image); } else { animation.Cancel(); } } _navigatedUri = null; } } }
private void ItemsGridView_Loaded(object sender, RoutedEventArgs e) { if (_navigatedUri != null) { // May be able to perform backwards Connected Animation var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("Image"); if (animation != null) { var item = Model.Items.Where(compare => compare.ImageUrl == _navigatedUri).First(); ItemsGridView.ScrollIntoView(item, ScrollIntoViewAlignment.Default); ItemsGridView.UpdateLayout(); var container = ItemsGridView.ContainerFromItem(item) as GridViewItem; if (container != null) { var root = (FrameworkElement)container.ContentTemplateRoot; var image = (Image)root.FindName("Image"); // Wait for image opened. In future Insider Preview releases, this won't be necessary. image.Opacity = 0; image.ImageOpened += (sender_, e_) => { image.Opacity = 1; animation.TryStart(image); }; } else { animation.Cancel(); } } _navigatedUri = null; } }