Public static T FindVisualChildByName{
This works for the Visual elements, not for the current elements of a parent: http://forums.silverlight.net/forums/p/85766/402922.aspx
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
string controlName = child.GetValue(Control.NameProperty) as string;
if (controlName == name)
{
return child as T;
}
else
{
T result = FindVisualChildByName
if (result != null)
return result;
}
}
return null;
}
Ref:
http://flatlinerdoa.spaces.live.com/Blog/cns!17124D03A9A052B0!566.entry
http://blogs.msdn.com/kmahone/archive/2009/03/29/visualtreehelper.aspx
http://enterpriseetc.com/post/VisualTreeHelper-Class-in-Silverlight.aspx
mercredi 28 avril 2010
Find a control in a WPF/Silverlight by name
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire