public override void OnApplyTemplate()
{
base.OnApplyTemplate();
tabRibbon = this;
root = GetTemplateChild("LayoutRoot") as Grid;
RibbonCollapse = root.Resources["RibbonCollapse"] as Storyboard;
RibbonExpand = root.Resources["RibbonExpand"] as Storyboard;
PushPin = GetTemplateChild("PushPin") as Button;
if (root != null)
{
root.MouseEnter += LayoutRoot_MouseEnter;
root.MouseLeave += LayoutRoot_MouseLeave;
}
if (RibbonExpand != null)
RibbonExpand.Completed += RibbonExpand_Completed;
if (PushPin != null)
PushPin.Click += PushPin_Click;
}