I redefined the control template in ResourceDictionary Generic.xaml . In this I added a button on which I wanted to add some events.
<Setter Property="Template"> <Setter.Value> --Added my button here. </Setter.Value> </Setter>
So in the Loaded event of control I did
Button b = (Button)mycontrol.Template.FindName("PARTName", mycontrol) //Add Events on my button
Some where on the Internet I read what I can do
public override void OnApplyTemplate() { base.OnApplyTemplate(); UIElement editingelement = GetTemplateChild("PART_EditingElement"); if (editingelement != null) {
When I tried to make this offer for GetTemplateChild , do not use.

So my question is:
source share