zoukankan      html  css  js  c++  java
  • Extensions

    public static partial class Extensions
        {
            public static T FindAncestor<T>(DependencyObject obj) where T : DependencyObject
            {
                while (obj != null)
                {
                    T o = obj as T;
                    if (o != null)
                        return o;

                    obj = VisualTreeHelper.GetParent(obj);
                }
                return null;
            }

            public static T FindAncestor<T>(this UIElement obj) where T : UIElement
            {
                return FindAncestor<T>((DependencyObject)obj);
            }

            public static void CollapseAllRow(this DataGrid dg)
            {
                foreach (var rowItem in dg.ItemsSource)
                {
                    // Ensures that all rows are loaded.
                    dg.ScrollIntoView(rowItem, dg.Columns.Last());

                    // Get the content of the cell.
                    FrameworkElement el = dg.Columns.Last().GetCellContent(rowItem);

                    // Retrieve the row which is parent of given element.
                    DataGridRow row = DataGridRow.GetRowContainingElement(el.Parent as FrameworkElement);

                    // Sometimes some rows for some reason can be null.
                    if (row != null)
                        row.DetailsVisibility = Visibility.Collapsed;

                }

            }
        }

  • 相关阅读:
    JQuery中$.ajax()方法参数详解
    overload和override的区别
    linux 安装jdk和tomcat
    linux链接外网手动设置
    RISC与CISCCPU构架
    32位与64位内存区别
    system 系统调用、gcc编译过程
    c helloworld
    C语言中 有符号数、无符号数、整数溢出 (转)
    samba安装
  • 原文地址:https://www.cnblogs.com/elaborateday/p/1831806.html
Copyright © 2011-2022 走看看