活动在Silverlight滚动结束时发射



我正在使用C#,Silverlight,Windows Phone的Visual Studio7。

我正在寻找一个滚动滚动完成滚动时发射的事件。我有兴趣获得某些元素的最终职位。

布局在滚动期间被触发了几次,但在滚动结束时并不始终如一。Manipulation CommpleteT在某些情况下有效,但是如果用户在滚动上进行"轻弹"动作,则在滚动停止移动之前进行操作。

请注意,我正在Silverlight和滚动事件(例如Scrollchanged)工作。

预先感谢。

我通过利用ScrollViewer的VisualStateGroup来解决此问题。

// uie is a UIElement
IEnumerable<ScrollViewer> svList = uie.GetVisualDescendants<ScrollViewer>();
if (svList.Count() > 0)
{
    // Visual States are always on the first child of the control
    FrameworkElement element = VisualTreeHelper.GetChild(svList.First<ScrollViewer>(), 0) as FrameworkElement;
    // getting all the visual state groups
    IList groups = VisualStateManager.GetVisualStateGroups(element);
    foreach (VisualStateGroup group in groups)
    {
        if (group.Name == "ScrollStates")
        {
            group.CurrentStateChanged += new EventHandler<VisualStateChangedEventArgs>(group_CurrentStateChanged);
        }
    }
}
private static void group_CurrentStateChanged(object sender, VisualStateChangedEventArgs e)
{
    if (e.NewState.Name == "NotScrolling")
    {
        isNotScrolling = true;
    }
    else
    {
        isNotScrolling = false;
    }
}

我遇到的唯一问题是滚动状态的状态变化很慢,因此应用程序触发的其他事件将在您的代码甚至注册滚动之前处理。

最新更新