コード例 #1
0
 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);
 }
コード例 #2
0
 public static double GetHorizontalScrollOffset(this ListBox list)
 {
     return((ExtensionMethods.FindVisualChild((FrameworkElement)list, "ScrollViewer") as ScrollViewer).HorizontalOffset);
 }
コード例 #3
0
 public static IEnumerable <FrameworkElement> GetVisualAncestors(this FrameworkElement node)
 {
     for (FrameworkElement parent = ExtensionMethods.GetVisualParent(node); parent != null; parent = ExtensionMethods.GetVisualParent(parent))
     {
         yield return(parent);
     }
 }
コード例 #4
0
 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))));
 }