Hi All, I have a Silverlight page which added several userControls. Is ther any way to get ID of all controls which added as childs of page. Appreciate if you can provide sample code. (C# or VB). Thanks
controls in silverlight inherits from FrameworkElement:UIElement:Visual:DependencyObject, which has dependency property named
NameProperty, so you should use the SetValue method to give the control some name.
RootCanvas
Member
10 Points
8 Posts
Get Controls
Feb 16, 2008 06:55 PM | LINK
Hi All, I have a Silverlight page which added several userControls. Is ther any way to get ID of all controls which added as childs of page. Appreciate if you can provide sample code. (C# or VB). Thanks
rambler.elf
Participant
806 Points
141 Posts
Re: Get Controls
Feb 16, 2008 07:17 PM | LINK
Hi,
List<string> lst = new List<string>(); foreach (var child in Children) lst.Add(child.Name)RootCanvas
Member
10 Points
8 Posts
Re: Re: Get Controls
Feb 17, 2008 04:25 PM | LINK
Hi rambler,
Thanks you for your response. its worked. BTW if possible could you pls let me know how can we set control's name property.
Thanks
rambler.elf
Participant
806 Points
141 Posts
Re: Re: Get Controls
Feb 17, 2008 10:37 PM | LINK
hi,
controls in silverlight inherits from FrameworkElement:UIElement:Visual:DependencyObject, which has dependency property named NameProperty, so you should use the SetValue method to give the control some name.
TextBlock txtB=new TextBlock();
txtB.SetValue(NameProperty,"testControl");
Children.Add(txtB);
RootCanvas
Member
10 Points
8 Posts
Re: Re: Re: Get Controls
Feb 18, 2008 04:21 PM | LINK
Hi rambler, thank you so much agian[Y]