Search code examples
windows-phone-7windows-phone-8listboxlonglistselector

How to keep LongListSelector's current group name on top


I'm sure it has been asked before, but i cant find the answer. Is it possible using the LongListSelector control to always show the name of the current group? Just like it works in the People hub.


Solution

  • This is just a snippet. Please modify it as necessary.

    var transform = llstItems.TransformToVisual(Application.Current.RootVisual);
    Point pointTarget = transform.Transform(new Point(0, 0));
    pointTarget.X += 5;
    pointTarget.Y += 6;
    List<UIElement> elements = (List<UIElement>)VisualTreeHelper.FindElementsInHostCoordinates(pointTarget, Application.Current.RootVisual);
    if (elements != null && elements.Count > 0)
    {
        TextBlock textGroupedHeader = elements[0] as TextBlock;
        if (textGroupedHeader != null)
        {
            Main.GroupTitle = textGroupedHeader.Text;
        }
    }