Control to find in Gridview

Posted by Venkatesh under WPF on 6/8/2011 | Points: 10 | Views : 2193 | Status : [Member] | Replies : 1
Hi,

How to find control like label in Gridview in WPF?

Thanks
Venkatesh.P




Responses

Posted by: Ndebata on: 6/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
First you need to know the RowIndex and ColumnIndex, I mean cell of the gridview,
Then
You can use this method to find out the Control you are looking for in that cell
public static T GetVisualChild<T>(Visual parent) where T : Visual

{
T child = default(T);
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
child = v as T;
if (child == null)
{
child = GetVisualChild<T>(v);
}
if (child != null)
{
break;
}
}
return child;
}


* Reference
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/709092a6-f68f-41f0-9282-fcd6caa0bb1a/

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response