是否可以从受保护的覆盖无效中取消订阅事件处理程序?
protected override void OnViewLoaded(object sender, ViewLoadedEventArg e)
{
base.OnViewLoaded(sender, e);
list = VisualTreeUtil.FindFirstInTree<ListView>(Application.Current.MainWindow, "ListView");
ConfigureAndSuperviseInputControls(this.list);
ScrollViewer scroll = VisualTreeUtil.FindFirstInTree<ScrollViewer>(this.list);
scroll.ScrollChanged+=new ScrollChangedEventHandler(scroll_ScrollChanged);
}
void scroll_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
ConfigureAndSuperviseInputControls(this.list);
ScrollViewer sb = e.OriginalSource as ScrollViewer;
if (sb.ContentVerticalOffset==sb.ScrollableHeight)
{
scroll.ScrollChanged-=new ScrollChangedEventHandler(scroll_ScrollChanged);
}
}
我的问题是我无法访问 scroll_ScrollChanged 方法中的滚动对象。