public void ScrollToCurrentOffset() { MainFlip.GetBindingExpression(FlipView.ItemsSourceProperty).UpdateSource(); var container = MainFlip.ContainerFromItem(this); var scrollViewer = FindChildrenObjectByType <ScrollViewer>(container); var store = new StoreToFiles(); var offset = store.LoadOffset(Thread); scrollViewer.ScrollToVerticalOffset(offset); this.MainFlip.SelectionChanged += MainFlip_SelectionChanged; //scrollViewer.ViewChanged += ScrollViewer_ViewChanged; }
private async void FlipViewOfSectionsItems_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (((FlipView)sender).SelectedItem == null) { return; } // http://stackoverflow.com/a/26611106/5303344 //HACKYFIX: Daniel note: Very hacky workaround for an api issue //Microsoft's api for getting item controls for the flipview item fail on the very first media selection change for some reason. Basically we ignore the //first media selection changed event but spawn a thread to redo the ignored selection changed, hopefully allowing time for whatever is going on //with the api to get things sorted out so we can call the "ContainerFromItem" function and actually get the control we need if (_hackyfix == 0 || _hackyfix == 1) { _hackyfix++; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { FlipViewOfSectionsItems_SelectionChanged(sender, e); }); return; } if (((FlipView)sender).SelectedItem.GetType().Name == "Item") { loadedItem = (Item)((FlipView)sender).SelectedItem; FlipView flipView = (FlipView)sender; FlipViewItem flipViewItemContainer = (FlipViewItem)flipView.ContainerFromItem(loadedItem); if (flipViewItemContainer == null) { return; } if (loadedItem.item_type == "text") { WebView webview = VisualTreeHelpers.FindChild <WebView>(flipViewItemContainer, "ItemWebView"); webview.NavigateToString(loadedItem.item_text); } } }
public void InitAnimation(InitOption Option) { if (compositor != null) { if (Option == InitOption.AroundImage) { for (int i = Flip.SelectedIndex > 2 ? Flip.SelectedIndex - 2 : 0; i < Flip.SelectedIndex + 2 && i < Flip.Items.Count; i++) { if (Flip.ContainerFromIndex(i) is UIElement Element) { var Visual = ElementCompositionPreview.GetElementVisual(Element); CenterPointAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("CenterPoint", CenterPointAnimation); Visual.StopAnimation("Scale.X"); ScaleAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("Scale.X", ScaleAnimation); Visual.StartAnimation("Scale.Y", ScaleAnimation); } } } else { foreach (var Visual in from Item in Flip.Items let Element = Flip.ContainerFromItem(Item) as UIElement where Element != null select ElementCompositionPreview.GetElementVisual(Element)) { CenterPointAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("CenterPoint", CenterPointAnimation); Visual.StopAnimation("Scale.X"); ScaleAnimation.SetReferenceParameter("visual", Visual); Visual.StartAnimation("Scale.X", ScaleAnimation); Visual.StartAnimation("Scale.Y", ScaleAnimation); } } } }