Can't find the parent of a templated control by type(!) (wpf)?

Control originalSource = e. OriginalSource; MyItemControl myItemControl = originalSource. TemplatedParent as MyItemControl; MyHeaderControl myHeaderControl = originalSource.

TemplatedParent as MyHeaderControl; if (MyItemControl! = null) .... else if (MyHeaderControl! = null) (see: http://msdn.microsoft.com/en-gb/library/system.windows.frameworkelement.templatedparent.aspx ).

Control originalSource = e. OriginalSource; MyItemControl myItemControl = originalSource. TemplatedParent as MyItemControl; MyHeaderControl myHeaderControl = originalSource.

TemplatedParent as MyHeaderControl; if (MyItemControl! = null) .... else if (MyHeaderControl! = null) .... (see: http://msdn.microsoft.com/en-gb/library/system.windows.frameworkelement.templatedparent.aspx).

OMG that's it! Thx! – Tenshiko Dec 2 '10 at 16:29 you're very welcome :) (I felt the enthusiasm) – David Dec 2 '10 at 17:04.

Check out VisualTreeHelper. GetParent, which will let you walk the visual tree where the controls have actually been instantiated through the template.

It does the same. According to GetParent() my Control looks like: – Tenshiko Dec 2 '10 at 16:01 grid-grid-textblock instead of control-grid-grid-textblock – Tenshiko Dec 2 '10 at 16:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions