private void TextView_ScrollOffsetChanged(object sender, EventArgs e) { var textView = (TextView)sender; if (DataContext == null) return; if (textView.DataContext != DataContext) return; ScrollOffsets.Remove(DataContext); ScrollOffsets.Add(DataContext, textView.ScrollOffset); }
private void OnDataContextChanged_Scroll(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue == null) return; object scrollOffset; if (ScrollOffsets.TryGetValue(e.NewValue, out scrollOffset)) { Dispatcher.BeginInvoke(new Action(() => { ScrollToHorizontalOffset(((Vector)scrollOffset).X); ScrollToVerticalOffset(((Vector)scrollOffset).Y); })); } }