/// <summary> /// Overriding to setup state. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); if (ContextMenuProperty.IsUnsetValue(this)) { MetroChrome chrome = null; var window = Window.GetWindow(this); if (window != null && ((chrome = window.GetFirstDescendent <MetroChrome>()) != null) && chrome.QuickAccessToolBar != null) { SetResourceReference(ContextMenuProperty, QuickAccessToolBar.AddItemContextMenuKey); } } }
/// <summary> /// Overriding to setup state. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); if (MetroUI.ThemeProperty.IsUnsetValue(this) && Owner != null) { var focused = FocusManager.GetFocusedElement(Owner); if (focused != null) { var theme = MetroUI.GetEffectiveTheme((UIElement)focused); MetroUI.SetTheme(this, theme); } else { MetroUI.SetTheme(this, MetroUI.GetTheme(Owner)); } } if (ChromeProperty.IsUnsetValue(this) && Chrome == null) { Chrome = new MetroChrome { ShowSystemMenu = false, HideMinimizeMaximizeButtons = true, FontWeight = FontWeights.Bold }; } }