Member_2_99151
asked on
How can I find a UIElement on a WPF application
Hi,
I have a number of Ellipses on the main interface to a WPF application.
I would like to change the properties of these programmatically, but I want to reference them by name (otherwise the code will be huge!!)
I would like something like this:
I know this is not the correct syntax, but is this approach possible???
Any help would be appreciated.
Best regards,
James
I have a number of Ellipses on the main interface to a WPF application.
I would like to change the properties of these programmatically, but I want to reference them by name (otherwise the code will be huge!!)
I would like something like this:
Ellipse mine = (Ellipse) UIElements.Find["ellipse12"];
I know this is not the correct syntax, but is this approach possible???
Any help would be appreciated.
Best regards,
James
ASKER
Hi,
Thanks for the info..
I have found that the following does this directly...
Int32 xElipseID = 3;
Ellipse myEllipse = (Ellipse) FindName("ellipse" + xElipseID.ToString());
Is this *correct* WPF coding ?
James
Thanks for the info..
I have found that the following does this directly...
Int32 xElipseID = 3;
Ellipse myEllipse = (Ellipse) FindName("ellipse" + xElipseID.ToString());
Is this *correct* WPF coding ?
James
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hee hee - point taken :-) Thanks
Helpfull links on that class that have some use ready links:
http://blogs.msdn.com/b/kmahone/archive/2009/03/29/visualtreehelper.aspx
http://amyokabir.wordpress.com/2010/03/01/my-visualtreehelper-search-the-visual-tree/