locked
Looping flipview control from last to first

    Question

  • Hello,

    How can I loop flipview from last item to the first item.

    Tuesday, February 25, 2014 9:29 AM

Answers

  • Hi ,

    Below is a sample using VisualTreeHelper. You can modify it and add your own code or even pass a grid or whatever. The FindVisualChildren is kind of a standard. The only thing you can change is the first loop.

    //searches for all buttons in flipview

      foreach (Button tb in FindVisualChildren<Button>(this.MyFlipView))
                {
                    tb.IsEnabled = true;  //this is an example

                }

     private static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
            {
                if (depObj == null)
                {
                    yield break;
                }

                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
                {
                    var child = VisualTreeHelper.GetChild(depObj, i);
                    if (child != null && child is T)
                    {
                        yield return (T)child;
                    }

                    foreach (var childOfChild in FindVisualChildren<T>(child))
                    {
                        yield return childOfChild;
                    }
                }
            }

    Tuesday, February 25, 2014 10:18 AM