protected override void OnAttached()
{
base.OnAttached ();
// Insert code that you would want run when the Behavior is attached to an object.
var dpd = DependencyPropertyDescriptor. FromProperty(ScrollViewer .VerticalOffsetProperty, AssociatedType);
dpd.AddValueChanged (
AssociatedObject,
(sender,
args) =>
{
RaiseReachingBottomEvent();
});
}
protected override void OnDetaching()
{
base.OnDetaching ();
// Insert code that you would want run when the Behavior is removed from an object.
}
private void RaiseReachingBottomEvent()
{
bool isReachingBottom = AssociatedObject. VerticalOffset >= AssociatedObject .ScrollableHeight;
if (isReachingBottom )
{
if (this .ReachingBottomEvent != null)
{
this.ReachingBottomEvent ();
}
}
}
public event Action ReachingBottomEvent;
}