利用silverlight 遍历父子控件通用方法
silverlight中datagrid找元素,真是麻烦,没有rows对象,无法遍历。从网上找来这些方法,挺好用的:
public class vthelper()
{
public t getparentobject(dependencyobject obj, string name) where t : frameworkelement
{
dependencyobject parent = visualtreehelper.getparent(obj);while (parent != null)
{
if (parent is t && (((t)parent).name == name | string.isnullorempty(name)))
{
return (t)parent;
}
parent = visualtreehelper.getparent(parent);
}
return null;
}public t getchildobject
(dependencyobject obj, string name) where t : frameworkelement
{
dependencyobject child = null;
t grandchild = null;for (int i = 0; i <= visualtreehelper.getchildrencount(obj) - 1; i++)
{
child = visualtreehelper.getchild(obj, i);if (child is t && (((t)child).name == name | string.isnullorempty(name)))
{
return (t)child;
}
else
{
grandchild = getchildobject(child, name);
if (grandchild != null)
return grandchild;
}
}
return null;
}public list
getchildobjects (dependencyobject obj, string name) where t : frameworkelement
{
dependencyobject child = null;
listchildlist = new list (); for (int i = 0; i <= visualtreehelper.getchildrencount(obj) - 1; i++)
{
child = visualtreehelper.getchild(obj, i);if (child is t && (((t)child).name == name || string.isnullorempty(name)))
{
childlist.add((t)child);
}
childlist.addrange(getchildobjects(child,""));
}
return childlist;
}
}
热血大作战 安卓最新版v2.1.166
下载凡尔赛法环免广告版 最新版v1.69.1
下载天煞异种 安卓版v1.0.21
下载十三月 (Undecember)最新官方中文版v3.26.0200
下载星露谷物语sve 安卓版v1.5.6.52
星露谷物语sve手机版是游戏的超大拓展Mod内容,全称Sta
动物园大亨 手机版v2.0
动物园大亨是一款模拟动物园经营的休闲放置游戏,采用了卡通画风
蜜蜂园林钞票不减反增版 v0.1.68
蜜蜂园林无限道具版是游戏的破解版本,在该版本中为玩家提供了足
幻想熔炉失落帝国的世界 安卓版v2.16.2
幻想熔炉失落帝国的世界是一款魔法卡通风格的城市模拟经营类游戏
我的女友是声优免广告 安卓版v1
我的女友是声优免广告是一款非常好玩的模拟经营类手游,玩家在游