Exemple #1
0
        public static Orientation GetItemsPanelOrientation(this ItemsControl itemsControl)
        {
            var itemsPresenter = itemsControl.GetVisualDescendant <ItemsPresenter>();

            if (itemsPresenter == null)
            {
                return(Orientation.Vertical);
            }

            var itemsPanel = VisualTreeHelper.GetChild(itemsPresenter, 0);

            if (itemsPanel == null)
            {
                return(Orientation.Vertical);
            }

            var orientationProperty = LateBinder.FindProperty(itemsPanel.GetType(), "Orientation");

            if (orientationProperty == null)
            {
                return(Orientation.Vertical);
            }

            return((Orientation)orientationProperty.GetValue(itemsPanel));
        }