/// <summary> /// When overridden in a derived class, is invoked whenever application code /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate(). /// </summary> public override void OnApplyTemplate() { // Clear cache cachedMeasures.Clear(); if (LauncherButton != null) LauncherButton.Click -= OnDialogLauncherButtonClick; LauncherButton = GetTemplateChild("PART_DialogLauncherButton") as Button; if (LauncherButton != null) { LauncherButton.Click += OnDialogLauncherButtonClick; if (LauncherKeys != null) KeyTip.SetKeys(LauncherButton, LauncherKeys); } popup = GetTemplateChild("PART_Popup") as Popup; if (popup != null) { Binding binding = new Binding("IsOpen"); binding.Mode = BindingMode.TwoWay; binding.Source = this; popup.SetBinding(Popup.IsOpenProperty, binding); } downGrid = GetTemplateChild("PART_DownGrid") as Grid; upPanel = GetTemplateChild("PART_UpPanel") as Panel; parentPanel = GetTemplateChild("PART_ParentPanel") as Panel; }
/// <summary> /// When overridden in a derived class, is invoked whenever application code /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate(). /// </summary> public override void OnApplyTemplate() { this.UnSubscribeEvents(); // Clear cache cachedMeasures.Clear(); LauncherButton = GetTemplateChild("PART_DialogLauncherButton") as Button; if (LauncherButton != null) { if (LauncherKeys != null) { KeyTip.SetKeys(LauncherButton, LauncherKeys); } } popup = GetTemplateChild("PART_Popup") as Popup; downGrid = GetTemplateChild("PART_DownGrid") as Grid; upPanel = GetTemplateChild("PART_UpPanel") as Panel; parentPanel = GetTemplateChild("PART_ParentPanel") as Panel; snappedImage = GetTemplateChild("PART_SnappedImage") as Image; this.SubscribeEvents(); }
static void OnDialogLauncherButtonKeyTipKeysChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RibbonGroupBox ribbonGroupBox = (RibbonGroupBox)d; if (ribbonGroupBox.LauncherButton != null) { KeyTip.SetKeys(ribbonGroupBox.LauncherButton, (string)e.NewValue); } }
// Updates keys for keytip access void UpdateKeyTips() { for (int i = 0; i < Math.Min(9, Items.Count); i++) { // 1, 2, 3, ... , 9 KeyTip.SetKeys(Items[i], (i + 1).ToString(CultureInfo.InvariantCulture)); } for (int i = 9; i < Math.Min(18, Items.Count); i++) { // 09, 08, 07, ... , 01 KeyTip.SetKeys(Items[i], "0" + (18 - i).ToString(CultureInfo.InvariantCulture)); } char startChar = 'A'; for (int i = 18; i < Math.Min(9 + 9 + 26, Items.Count); i++) { // 0A, 0B, 0C, ... , 0Z KeyTip.SetKeys(Items[i], "0" + startChar++); } }
// Updates keys for keytip access private static void DefaultUpdateKeyTips(QuickAccessToolBar quickAccessToolBar) { for (var i = 0; i < Math.Min(9, quickAccessToolBar.Items.Count); i++) { // 1, 2, 3, ... , 9 KeyTip.SetKeys(quickAccessToolBar.Items[i], (i + 1).ToString(CultureInfo.InvariantCulture)); } for (var i = 9; i < Math.Min(18, quickAccessToolBar.Items.Count); i++) { // 09, 08, 07, ... , 01 KeyTip.SetKeys(quickAccessToolBar.Items[i], "0" + (18 - i).ToString(CultureInfo.InvariantCulture)); } var startChar = 'A'; for (var i = 18; i < Math.Min(9 + 9 + 26, quickAccessToolBar.Items.Count); i++) { // 0A, 0B, 0C, ... , 0Z KeyTip.SetKeys(quickAccessToolBar.Items[i], "0" + startChar++); } }