Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to obtain the controls list of a window

 
 
Old 01-23-2007   #1 (permalink)
Thierry


 
 

How to obtain the controls list of a window

hi all

i would obtain the controls list of a window (same as the this.Controls
property of a winform)

is there any method or property to do this ?

thanks for your help !


--
Thierry

My System SpecsSystem Spec
Old 01-24-2007   #2 (permalink)
Bill Henning


 
 

Re: How to obtain the controls list of a window

It's up to the control's implementor to provide access to its logical
parent/children. However you can walk the visual tree by using the
VisualTreeHelper class. There are static methods like GetParent, GetChild,
GetChildrenCount, etc. on there.

--

Bill Henning
Actipro Software

WPF Wizard Control -
http://www.actiprosoftware.com/Produ...d/Default.aspx



"Thierry" <newsgroup@delacroix62.fr> wrote in message
news6543AF1-0524-4D2F-A211-92B19031A147@microsoft.com...
> hi all
>
> i would obtain the controls list of a window (same as the this.Controls
> property of a winform)
>
> is there any method or property to do this ?
>
> thanks for your help !
>
>
> --
> Thierry



My System SpecsSystem Spec
Old 01-24-2007   #3 (permalink)
Stoitcho Goutsev \(100\)


 
 

Re: How to obtain the controls list of a window

You can use control's VisualChildrenCount property and GetVisualChild
method. These members are protected so you can use them only of you derive
from some control. For other cases use VisualTreeHelper and
LogicalTreeHelper classes.


--
HTH
Stoitcho Goutsev (100)

"Bill Henning" <no_spam@hotmail.com> wrote in message
news:OhkAWJ7PHHA.404@TK2MSFTNGP02.phx.gbl...
> It's up to the control's implementor to provide access to its logical
> parent/children. However you can walk the visual tree by using the
> VisualTreeHelper class. There are static methods like GetParent,
> GetChild, GetChildrenCount, etc. on there.
>
> --
>
> Bill Henning
> Actipro Software
>
> WPF Wizard Control -
> http://www.actiprosoftware.com/Produ...d/Default.aspx
>
>
>
> "Thierry" <newsgroup@delacroix62.fr> wrote in message
> news6543AF1-0524-4D2F-A211-92B19031A147@microsoft.com...
>> hi all
>>
>> i would obtain the controls list of a window (same as the this.Controls
>> property of a winform)
>>
>> is there any method or property to do this ?
>>
>> thanks for your help !
>>
>>
>> --
>> Thierry

>
>



My System SpecsSystem Spec
Old 01-24-2007   #4 (permalink)
Thierry


 
 

Re: How to obtain the controls list of a window

hi thanks stoitcho and bill

it works with LogicalTreeHelper but not with VisualTree

in the window constructor

foreach (object child in LogicalTreeHelper.GetChildren(this)) works

but VisualTreeHelper.GetChildrenCount(this) always return 0 !




"Stoitcho Goutsev (100)" <100@100.com> a écrit dans le message de
news:u3Pbs78PHHA.780@TK2MSFTNGP03.phx.gbl...
> You can use control's VisualChildrenCount property and GetVisualChild
> method. These members are protected so you can use them only of you derive
> from some control. For other cases use VisualTreeHelper and
> LogicalTreeHelper classes.
>
>
> --
> HTH
> Stoitcho Goutsev (100)
>
> "Bill Henning" <no_spam@hotmail.com> wrote in message
> news:OhkAWJ7PHHA.404@TK2MSFTNGP02.phx.gbl...
>> It's up to the control's implementor to provide access to its logical
>> parent/children. However you can walk the visual tree by using the
>> VisualTreeHelper class. There are static methods like GetParent,
>> GetChild, GetChildrenCount, etc. on there.
>>
>> --
>>
>> Bill Henning
>> Actipro Software
>>
>> WPF Wizard Control -
>> http://www.actiprosoftware.com/Produ...d/Default.aspx
>>
>>
>>
>> "Thierry" <newsgroup@delacroix62.fr> wrote in message
>> news6543AF1-0524-4D2F-A211-92B19031A147@microsoft.com...
>>> hi all
>>>
>>> i would obtain the controls list of a window (same as the this.Controls
>>> property of a winform)
>>>
>>> is there any method or property to do this ?
>>>
>>> thanks for your help !
>>>
>>>
>>> --
>>> Thierry

>>
>>

>
>


My System SpecsSystem Spec
Old 01-24-2007   #5 (permalink)
Stoitcho Goutsev \(100\)


 
 

Re: How to obtain the controls list of a window

It is possible that there is a logical tree, but the vsiual tree doesn't
exist.

What is the control you are playing with? If it is a control that you wrote
make sure that you override and provide implementation for
VisualChildrenCount and GetVisualChild members. These are the methods that
the VisualTreeHelper uses to walk the visual tree.


--
Stoitcho Goutsev (100)

"Thierry" <newsgroup@delacroix62.fr> wrote in message
news:1294C214-8329-464A-9F96-5118EAD8C8E0@microsoft.com...
> hi thanks stoitcho and bill
>
> it works with LogicalTreeHelper but not with VisualTree
>
> in the window constructor
>
> foreach (object child in LogicalTreeHelper.GetChildren(this)) works
>
> but VisualTreeHelper.GetChildrenCount(this) always return 0 !
>
>
>
>
> "Stoitcho Goutsev (100)" <100@100.com> a écrit dans le message de
> news:u3Pbs78PHHA.780@TK2MSFTNGP03.phx.gbl...
>> You can use control's VisualChildrenCount property and GetVisualChild
>> method. These members are protected so you can use them only of you
>> derive from some control. For other cases use VisualTreeHelper and
>> LogicalTreeHelper classes.
>>
>>
>> --
>> HTH
>> Stoitcho Goutsev (100)
>>
>> "Bill Henning" <no_spam@hotmail.com> wrote in message
>> news:OhkAWJ7PHHA.404@TK2MSFTNGP02.phx.gbl...
>>> It's up to the control's implementor to provide access to its logical
>>> parent/children. However you can walk the visual tree by using the
>>> VisualTreeHelper class. There are static methods like GetParent,
>>> GetChild, GetChildrenCount, etc. on there.
>>>
>>> --
>>>
>>> Bill Henning
>>> Actipro Software
>>>
>>> WPF Wizard Control -
>>> http://www.actiprosoftware.com/Produ...d/Default.aspx
>>>
>>>
>>>
>>> "Thierry" <newsgroup@delacroix62.fr> wrote in message
>>> news6543AF1-0524-4D2F-A211-92B19031A147@microsoft.com...
>>>> hi all
>>>>
>>>> i would obtain the controls list of a window (same as the
>>>> this.Controls property of a winform)
>>>>
>>>> is there any method or property to do this ?
>>>>
>>>> thanks for your help !
>>>>
>>>>
>>>> --
>>>> Thierry
>>>
>>>

>>
>>

>



My System SpecsSystem Spec
Old 01-24-2007   #6 (permalink)
Thierry


 
 

Re: How to obtain the controls list of a window

hi

in fact i want to obtain all the control with an existing binding to add
validation rule, maxlenght, etc..

i'm storing the rules in a custm attribute of the property of the object

the object is the datacontext and i bind the property to the control
(textbox, slider, ect...)

so in the window constructor i want to enumerate the controls of this window
an detect if a binding exist and in this case
if the binding property contains a custom attribute i want to apply
validation rules etc....

"Stoitcho Goutsev (100)" <100@100.com> a écrit dans le message de
news:%233$yUT$PHHA.3944@TK2MSFTNGP06.phx.gbl...
> It is possible that there is a logical tree, but the vsiual tree doesn't
> exist.
>
> What is the control you are playing with? If it is a control that you
> wrote make sure that you override and provide implementation for
> VisualChildrenCount and GetVisualChild members. These are the methods that
> the VisualTreeHelper uses to walk the visual tree.
>
>
> --
> Stoitcho Goutsev (100)
>
> "Thierry" <newsgroup@delacroix62.fr> wrote in message
> news:1294C214-8329-464A-9F96-5118EAD8C8E0@microsoft.com...
>> hi thanks stoitcho and bill
>>
>> it works with LogicalTreeHelper but not with VisualTree
>>
>> in the window constructor
>>
>> foreach (object child in LogicalTreeHelper.GetChildren(this)) works
>>
>> but VisualTreeHelper.GetChildrenCount(this) always return 0 !
>>
>>
>>
>>
>> "Stoitcho Goutsev (100)" <100@100.com> a écrit dans le message de
>> news:u3Pbs78PHHA.780@TK2MSFTNGP03.phx.gbl...
>>> You can use control's VisualChildrenCount property and GetVisualChild
>>> method. These members are protected so you can use them only of you
>>> derive from some control. For other cases use VisualTreeHelper and
>>> LogicalTreeHelper classes.
>>>
>>>
>>> --
>>> HTH
>>> Stoitcho Goutsev (100)
>>>
>>> "Bill Henning" <no_spam@hotmail.com> wrote in message
>>> news:OhkAWJ7PHHA.404@TK2MSFTNGP02.phx.gbl...
>>>> It's up to the control's implementor to provide access to its logical
>>>> parent/children. However you can walk the visual tree by using the
>>>> VisualTreeHelper class. There are static methods like GetParent,
>>>> GetChild, GetChildrenCount, etc. on there.
>>>>
>>>> --
>>>>
>>>> Bill Henning
>>>> Actipro Software
>>>>
>>>> WPF Wizard Control -
>>>> http://www.actiprosoftware.com/Produ...d/Default.aspx
>>>>
>>>>
>>>>
>>>> "Thierry" <newsgroup@delacroix62.fr> wrote in message
>>>> news6543AF1-0524-4D2F-A211-92B19031A147@microsoft.com...
>>>>> hi all
>>>>>
>>>>> i would obtain the controls list of a window (same as the
>>>>> this.Controls property of a winform)
>>>>>
>>>>> is there any method or property to do this ?
>>>>>
>>>>> thanks for your help !
>>>>>
>>>>>
>>>>> --
>>>>> Thierry
>>>>
>>>>
>>>
>>>

>>

>
>


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Showing contacts list in main window Vista mail
Identify the list of controls in an app PowerShell
Get Process List from window Service Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46