Silverlight 锚标记功能?

发布于 2024-08-29 14:27:35 字数 263 浏览 3 评论 0原文

我在堆栈面板中有一堆用户控件(大约 15 个,每个记录一个),这些控件一直延伸到我的页面。我将其放入滚动查看器中,以便用户不必滚动浏览器,而只需滚动滚动查看器面板即可。

任何人都知道如何以编程方式滚动到我的堆栈面板中的特定用户控件。我希望顶部有一个下拉列表来代表每条记录,以便在选择时滚动查看器滚动到该用户控件。

有什么想法吗?我看到滚动查看器有一个 ScrollToVerticalOffset() 方法,但我不知道如何计算这些控件在堆栈面板中的偏移量。

谢谢!

I have a a bunch of user controls(about 15, one for each record) in a stackpanel that extends way down my page. I put this in a scrollviewer so that the user wouldn't have to scroll the browser but instead can just scroll the scrollviewer panel.

ANyone know how to programatically scroll to a specific user control in my stack panel. I want a dropdown at the top toi represetn each record so that when selected the scroll viewer scrolls to that user control.

ANy thoughts? I see that the scrollviewer has a ScrollToVerticalOffset() method but I don't know how I would calculate the offset of these controls in the stackpanel.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2024-09-05 14:27:35

我想像下面这样的东西会起作用:

void ScrollToUserControl(UserControl uc)
{
    double amountToScroll = 0;
    for (int i = 0; i < stackPanel.Children.Count; i++)
    {
        if (stackPanel.Children[i] == uc)
            break;

        amountToScroll += stackPanel.Children[i].ActualHeight;

    }

    scrollViewer.UpdateLayout();
    scrollViewer.ScrollToVerticalOffset(amountToScroll);
}

I imagine something like the following would work:

void ScrollToUserControl(UserControl uc)
{
    double amountToScroll = 0;
    for (int i = 0; i < stackPanel.Children.Count; i++)
    {
        if (stackPanel.Children[i] == uc)
            break;

        amountToScroll += stackPanel.Children[i].ActualHeight;

    }

    scrollViewer.UpdateLayout();
    scrollViewer.ScrollToVerticalOffset(amountToScroll);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文