|
@@ -173,6 +173,45 @@ namespace PDF_Office.Helper
|
|
catch { return null; }
|
|
catch { return null; }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static T FindVisualChildByName<T>(DependencyObject parent, string name) where T : DependencyObject
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ var child = VisualTreeHelper.GetChild(parent, i);
|
|
|
|
+
|
|
|
|
+ string controlName = child.GetValue(System.Windows.Controls.Control.NameProperty) as string;
|
|
|
|
+
|
|
|
|
+ if (controlName == name)
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ return child as T;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ else
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ T result = FindVisualChildByName<T>(child, name);
|
|
|
|
+
|
|
|
|
+ if (result != null)
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 从页码集合获取页码字符串,如1,2,3 转换成1-3
|
|
/// 从页码集合获取页码字符串,如1,2,3 转换成1-3
|
|
/// </summary>
|
|
/// </summary>
|