public override void OnApplyTemplate() { base.OnApplyTemplate(); // NOTE: Do not use GetTemplateChild(), because it will only find direct descendants. // Also refer to the MSDN Comment of GetTemplateChild() (shown in IntelliSense). // This is a common mistake. // // NOTE: FindName() also exist for this (from FrameworkElement), but we want to find // on the _template_ mCenterButton = Template.FindName("PART_Button", this) as Button; if (null != mCenterButton) { mCenterButton.Click += new System.Windows.RoutedEventHandler(mCenterButton_Click); mCenterButton.MouseEnter += new MouseEventHandler(MenuKillerItem_MouseEnter); } mPanel = Template.FindName("PART_Panel", this) as CircularPanel; mAlignPanel = Template.FindName("PART_AlignPanel", this) as ReferenceAlignPanel; if (null != mPanel) { mPanel.ChildArranged += new CircularPanel.OnChildArranged(mPanel_ChildArranged); } }