ITemplatedItemsView<Cell> TemplatedItemsView => Element;
WpfScrollBarVisibility? _defaultHorizontalScrollVisibility;
WpfScrollBarVisibility? _defaultVerticalScrollVisibility;
+ ScrollViewer _scrollViewer;
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
var templatedItems = ((ITemplatedItemsView<Cell>)e.OldElement).TemplatedItems;
templatedItems.CollectionChanged -= OnCollectionChanged;
templatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged;
+ if (Control != null)
+ {
+ Control.MouseUp -= OnNativeMouseUp;
+ Control.KeyUp -= OnNativeKeyUp;
+ Control.TouchUp -= OnNativeTouchUp;
+ Control.StylusUp -= OnNativeStylusUp;
+ Control.Loaded -= ControlOnLoaded;
+ }
+ if (_scrollViewer != null)
+ {
+ _scrollViewer.ScrollChanged -= SendScrolled;
+ }
}
if (e.NewElement != null)
Control.KeyUp += OnNativeKeyUp;
Control.TouchUp += OnNativeTouchUp;
Control.StylusUp += OnNativeStylusUp;
+ Control.Loaded += ControlOnLoaded;
}
// Suscribe element events
base.OnElementChanged(e);
}
+
+ void ControlOnLoaded(object sender, RoutedEventArgs e)
+ {
+ _scrollViewer = Control.FindVisualChild<ScrollViewer>();
+ if (_scrollViewer != null)
+ {
+ _scrollViewer.ScrollChanged += SendScrolled;
+ }
+ }
+
+ void SendScrolled(object sender, ScrollChangedEventArgs e)
+ {
+ var args = new ScrolledEventArgs(0, _scrollViewer.VerticalOffset);
+ Element?.SendScrolled(args);
+ }
+
void OnElementScrollToRequested(object sender, ScrollToRequestedEventArgs e)
{
var scrollArgs = (ITemplatedItemsListScrollToRequestedEventArgs)e;
Control.KeyUp -= OnNativeKeyUp;
Control.TouchUp -= OnNativeTouchUp;
Control.StylusUp -= OnNativeStylusUp;
+ Control.Loaded -= ControlOnLoaded;
+ }
+ if (_scrollViewer != null)
+ {
+ _scrollViewer.ScrollChanged -= SendScrolled;
}
if (Element != null)