用户列表页面完成 订单列表页面开始 10%
This commit is contained in:
1 parent
25cdf642bf
commit
edc7913637
52 files changed
+2032
-365
No files matched your search
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace _29WxOrderWpf.Utils
|
||||
{
|
||||
public class UiCtrlUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// 查找模板控件的子控件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
|
||||
if (child != null && child is T)
|
||||
{
|
||||
return (T)child;
|
||||
}
|
||||
else
|
||||
{
|
||||
T childOfChild = FindVisualChild<T>(child);
|
||||
if (childOfChild != null)
|
||||
{
|
||||
return childOfChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找模板控件的子控件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="xName"></param>
|
||||
/// <returns></returns>
|
||||
public static T FindVisualChild<T>(DependencyObject obj, string xName) where T : DependencyObject
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
|
||||
string controlName = child?.GetValue(Control.NameProperty) as string;
|
||||
if (controlName == xName)
|
||||
{
|
||||
return (T)child;
|
||||
}
|
||||
else
|
||||
{
|
||||
T childOfChild = FindVisualChild<T>(child, xName);
|
||||
if (childOfChild != null)
|
||||
{
|
||||
return childOfChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user