public override void OnApplyTemplate() { base.OnApplyTemplate(); ToggleButton dropDownButton = Template.FindName("PART_DropDownButton", this) as ToggleButton; popup = Template.FindName("PART_Popup", this) as Popup; if (!IsEditable) { this.IsReadOnly = true; } DropDownContent.SetValue(TextBoxBase.IsReadOnlyProperty, false); popup.Opened += (s, e) => { DropDownContent.Focus(); }; popup.RequestBringIntoView += new RequestBringIntoViewEventHandler(popup_RequestBringIntoView); if (dropDownButton != null) { dropDownButton.Click += (s, e) => { e.Handled = true; RaiseEvent(new RoutedEventArgs(DialogButtonClickEvent, this)); }; } Thumb thumb = Template.FindName("PART_ResizeGrip", this) as Thumb; if (thumb != null) { thumb.DragDelta += DragDeltaEventHandler; } dropDownContentHost = Template.FindName("PART_DropDownContentHost", this) as ContentPresenter; if (dropDownContentHost != null) { dropDownContentHost.Content = DropDownContent; } }