public override void OnApplyTemplate() { // Should be called first // See http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.onapplytemplate(v=vs.110).aspx base.OnApplyTemplate(); _contentPresenter = (ContentPresenter)Template.FindName(ContentPresenterName, this); _ribbonHost = (Border)Template.FindName(RibbonHostName, this); _statusBar = (StatusBar)Template.FindName(StatusBarName, this); if (_ribbonOptionsPopup != null) { _ribbonOptionsPopup.MouseUp -= OnRibbonOptionsPopupMouseUp; } _ribbonOptionsPopup = (Popup)Template.FindName(RibbonOptionsPopupName, this); _ribbonOptionsPopup.DataContext = this; _ribbonOptionsPopup.MouseUp += OnRibbonOptionsPopupMouseUp; if (_ribbonOptionsList != null) { _ribbonOptionsList.SelectionChanged -= OnRibbonOptionSelectionChanged; } _ribbonOptionsList = (ListView)Template.FindName(RibbonOptionsListName, this); _ribbonOptionsList.SelectionChanged += OnRibbonOptionSelectionChanged; _ribbonOptionsList.Items.AddRange(new[] { new RibbonOption { Title = Properties.Resources.AutoHideRibbonTitle, Description = Properties.Resources.AutoHideRibbonDescription, Visibility = RibbonState.Hidden, ImageSource = new BitmapImage(new Uri("/Crystalbyte.Ribbon;component/Assets/autohide.png", UriKind.Relative)) }, new RibbonOption { Title = Properties.Resources.ShowTabsTitle, Description = Properties.Resources.ShowTabsDescription, Visibility = RibbonState.Tabs, ImageSource = new BitmapImage(new Uri("/Crystalbyte.Ribbon;component/Assets/show.tabs.png", UriKind.Relative)) }, new RibbonOption { Title = Properties.Resources.ShowTabsAndCommandsTitle, Description = Properties.Resources.ShowTabsAndCommandsDescription, Visibility = RibbonState.TabsAndCommands, ImageSource = new BitmapImage(new Uri("/Crystalbyte.Ribbon;component/Assets/show.tabs.commands.png", UriKind.Relative)) } }); _appMenuHost = (Grid)Template.FindName(ApplicationMenuHostName, this); if (_appMenuOpenStoryboard != null) { _appMenuOpenStoryboard.Completed -= OnAppMenuOpened; } _appMenuOpenStoryboard = (Storyboard)_appMenuHost.FindResource("OpenApplicationMenuStoryboard"); _appMenuOpenStoryboard.Completed += OnAppMenuOpened; if (_appMenuCloseStoryboard != null) { _appMenuCloseStoryboard.Completed -= OnAppMenuClosed; } _appMenuCloseStoryboard = (Storyboard)_appMenuHost.FindResource("CloseApplicationMenuStoryboard"); _appMenuCloseStoryboard.Completed += OnAppMenuClosed; SyncRibbonOptionsSelection(); }