我如何获得图表系列? 父母的父母的详细信息?

发布于 2024-08-01 23:35:54 字数 180 浏览 11 评论 0原文

我在 silverlight 上获取图表系列的祖先时遇到一些困难。

我可以获取父级,但它是一种 Primitive 类型,然后我可以通过指定类型来获取该父级的父级,但是,我不确定当它到达图表时可以达到多少级别,我想查看图表。

有人可以指导我在代码中执行此操作而不指定父级的类型吗?

谢谢

I am having some difficulties of getting the ancestor of a chart series on silverlight.

I can get the parent, but it is a type of Primitive, and then I can get to the parent of that parent by specifying the type, however, I am not sure how many level deep can that be when it reaches to the Chart, and I would like to get to the Chart.

Can someone guide me to do that in code without specifying the type of the parent.

Thanks

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

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

发布评论

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

评论(1

世界如花海般美丽 2024-08-08 23:35:55

可能有一个建议...

我还没有尝试过,但是通过 FrameworkElement 上的 Name 属性进行搜索怎么样?

public static FrameworkElement FindAncestorByName(FrameworkElement element, string name)
{
    while (element != null)
    {
        if (element.Name == name)
            return element;

        DependencyObject obj = VisualTreeHelper.GetParent(element);
        element = obj as FrameworkElement;
    }
    return null;
}

当 VisualTree 中存在不是 FrameworkElement 的 DependencyObject 时,这可能不会返回任何内容。
但我认为值得一试......

I might have a suggestion...

I haven't tried it but what about searching by the Name property on a FrameworkElement?

public static FrameworkElement FindAncestorByName(FrameworkElement element, string name)
{
    while (element != null)
    {
        if (element.Name == name)
            return element;

        DependencyObject obj = VisualTreeHelper.GetParent(element);
        element = obj as FrameworkElement;
    }
    return null;
}

This could return nothing when there is a DependencyObject in the VisualTree which is not a FrameworkElement.
But I think this is worth a shot...

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