private void OnLoaded(object sender, RoutedEventArgs e) { var scrollViewer = ScrollingHost as ScrollViewer; if (scrollViewer == null && ScrollingHost != null) { scrollViewer = ScrollingHost.Descendants <ScrollViewer>().FirstOrDefault() as ScrollViewer; } if (scrollViewer == null) { return; } var props = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer); if (props == null) { return; } if (VerticalAlignment == VerticalAlignment.Top) { _animation = _compositor.CreateExpressionAnimation("Max(Scroll.Translation.Y, 0)"); _animation.SetReferenceParameter("Scroll", props); _visual.StopAnimation("Size.Y"); _visual.StartAnimation("Size.Y", _animation); } }
private void OnLoaded(object sender, RoutedEventArgs e) { var scrollViewer = ScrollingHost as ScrollViewer; if (scrollViewer == null && ScrollingHost != null) { scrollViewer = ScrollingHost.Descendants <ScrollViewer>().FirstOrDefault(); } if (scrollViewer == null || _topScrim == null || _bottomScrim == null) { return; } _scrollViewer = scrollViewer; _propertySet = Window.Current.Compositor.CreatePropertySet(); _propertySet.InsertScalar("ScrollableHeight", (float)scrollViewer.ScrollableHeight); var top = ElementCompositionPreview.GetElementVisual(_topScrim); var bottom = ElementCompositionPreview.GetElementVisual(_bottomScrim); var props = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer); var topAnimation = Window.Current.Compositor.CreateExpressionAnimation("Min(-(Scroll.Translation.Y / 32), 1)"); topAnimation.SetReferenceParameter("Scroll", props); topAnimation.SetReferenceParameter("Props", _propertySet); var bottomAnimation = Window.Current.Compositor.CreateExpressionAnimation("Min((Props.ScrollableHeight + Scroll.Translation.Y) / 32, 1)"); bottomAnimation.SetReferenceParameter("Scroll", props); bottomAnimation.SetReferenceParameter("Props", _propertySet); top.StartAnimation("Scale.Y", topAnimation); bottom.StartAnimation("Scale.Y", bottomAnimation); bottom.CenterPoint = new Vector3(0, 32, 0); if (scrollViewer.Content is FrameworkElement element) { element.SizeChanged += OnSizeChanged; } }
private async void Hyperlink_Click(TLTextUrl urlText) { if (urlText.WebPageId == _webpageId) { var fragmentStart = urlText.Url.IndexOf('#'); if (fragmentStart > 0) { var name = urlText.Url.Substring(fragmentStart + 1); if (_anchors.TryGetValue(name, out Border anchor)) { ScrollingHost.ScrollIntoView(anchor); //anchor.StartBringIntoView(); return; if (_scrollingHost == null) { _scrollingHost = ScrollingHost.Descendants <ScrollViewer>().FirstOrDefault() as ScrollViewer; } if (_scrollingHost != null) { var transform = anchor.TransformToVisual(ScrollingHost.ItemsPanelRoot); var position = transform.TransformPoint(new Point()); _scrollingHost.ChangeView(null, Math.Max(0, position.Y - 8), null, false); } } } } else if (urlText.WebPageId != 0) { var protoService = (MTProtoService)MTProtoService.Current; protoService.SendInformativeMessageInternal <TLWebPageBase>("messages.getWebPage", new TLMessagesGetWebPage { Url = urlText.Url, Hash = 0 }, result => { Execute.BeginOnUIThread(() => { ViewModel.NavigationService.Navigate(typeof(InstantPage), result); }); }, fault => { Debugger.Break(); }); } else { var url = urlText.Url; if (url.StartsWith("http") == false) { url = "http://" + url; } if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) { if (MessageHelper.IsTelegramUrl(uri)) { MessageHelper.HandleTelegramUrl(urlText.Url); } else { await Launcher.LaunchUriAsync(uri); } } } }