public static VisualStateGroup GetVisualStateGroup(this FrameworkElement root, string groupName) { foreach (FrameworkElement frameworkElement in ExtensionMethods.PrependWith <FrameworkElement>(ExtensionMethods.GetVisualAncestors(root), root)) { foreach (object obj in (IEnumerable)VisualStateManager.GetVisualStateGroups(frameworkElement)) { VisualStateGroup visualStateGroup = obj as VisualStateGroup; if (visualStateGroup != null && visualStateGroup.Name == groupName) { return(visualStateGroup); } } } return((VisualStateGroup)null); }
public static double GetHorizontalScrollOffset(this ListBox list) { return((ExtensionMethods.FindVisualChild((FrameworkElement)list, "ScrollViewer") as ScrollViewer).HorizontalOffset); }
public static IEnumerable <FrameworkElement> GetVisualAncestors(this FrameworkElement node) { for (FrameworkElement parent = ExtensionMethods.GetVisualParent(node); parent != null; parent = ExtensionMethods.GetVisualParent(parent)) { yield return(parent); } }
public static IEnumerable <T> GetVisibleItems <T>(this IEnumerable <T> items, FrameworkElement viewport, Orientation orientation) where T : FrameworkElement { return(Enumerable.TakeWhile <T>(Enumerable.SkipWhile <T>(items, (Func <T, bool>)(item => ExtensionMethods.TestVisibility((FrameworkElement)item, viewport, orientation, false))), (Func <T, bool>)(item => ExtensionMethods.TestVisibility((FrameworkElement)item, viewport, orientation, true)))); }