public override void OnApplyTemplate()
{
CoerceValue(ControlSizeDefinitionProperty);
base.OnApplyTemplate();
EditableTextBoxSite = GetTemplateChild(EditableTextBoxTemplateName) as TextBox;
// EditableTextBoxSite should have been set by now if it's in the visual tree
if (EditableTextBoxSite != null)
{
EditableTextBoxSite.TextChanged += new TextChangedEventHandler(OnEditableTextBoxTextChanged);
EditableTextBoxSite.SelectionChanged += new RoutedEventHandler(OnEditableTextBoxSelectionChanged);
}
// At startup ComboBox needs SelectedItem from its first RibbonGallery in order to populate its TextBox.
// RibbonGallery needs to be hooked up to the Visual tree, so that its DataContext is inherited.
// Similarly RibbonGalleryCategory and RibbonGalleryItem should be in Visual tree to extract SelectedItem and the container for the SelectedItem
// Therefore its not sufficient to just generate containers, we need a full Layout on RibbonGallery.
if (Popup != null && Popup.Child != null)
{
Popup.Child.Measure(new Size());
UpdateFirstGallery();
}
}