// Find key tips on the given element private void FindKeyTips(UIElement element, bool hide) { this.Log("FindKeyTips"); var children = LogicalTreeHelper.GetChildren(element); foreach (var item in children) { var child = item as UIElement; if (child == null || child.Visibility != Visibility.Visible) { continue; } var groupBox = child as RibbonGroupBox; var keys = KeyTip.GetKeys(child); if (keys != null) { // Gotcha! var keyTip = new KeyTip { Content = keys, Visibility = hide ? Visibility.Collapsed : Visibility.Visible }; // Add to list & visual // children collections this.keyTips.Add(keyTip); this.AddVisualChild(keyTip); this.associatedElements.Add(child); if (groupBox != null) { if (groupBox.State == RibbonGroupBoxState.Collapsed) { keyTip.Visibility = Visibility.Visible; this.FindKeyTips(child, true); continue; } else { keyTip.Visibility = Visibility.Collapsed; } } else { // Bind IsEnabled property var binding = new Binding("IsEnabled") { Source = child, Mode = BindingMode.OneWay }; keyTip.SetBinding(IsEnabledProperty, binding); continue; } } if (groupBox != null && groupBox.State == RibbonGroupBoxState.Collapsed) { this.FindKeyTips(child, true); } else { this.FindKeyTips(child, hide); } } }
// Find key tips on the given element private void FindKeyTips(UIElement element, bool hide) { this.Log("FindKeyTips"); var children = GetVisibleChildren(element); foreach (var child in children) { var groupBox = child as RibbonGroupBox; var keys = KeyTip.GetKeys(child); if (keys != null) { // Gotcha! var keyTip = new KeyTip { Content = keys, Visibility = hide ? Visibility.Collapsed : Visibility.Visible }; // Add to list & visual // children collections this.keyTips.Add(keyTip); this.AddVisualChild(keyTip); this.associatedElements.Add(child); if (groupBox != null) { if (groupBox.State == RibbonGroupBoxState.Collapsed) { keyTip.Visibility = Visibility.Visible; this.FindKeyTips(child, true); continue; } else { keyTip.Visibility = Visibility.Collapsed; } } else { // Bind IsEnabled property var binding = new Binding("IsEnabled") { Source = child, Mode = BindingMode.OneWay }; keyTip.SetBinding(IsEnabledProperty, binding); continue; } } if (groupBox != null && groupBox.State == RibbonGroupBoxState.Collapsed) { this.FindKeyTips(child, true); } else { this.FindKeyTips(child, hide); } } }
// Find key tips on the given element private void FindKeyTips(UIElement element, bool hide) { this.Log("FindKeyTips"); IEnumerable children = LogicalTreeHelper.GetChildren(element); foreach (object item in children) { UIElement child = item as UIElement; RibbonGroupBox groupBox = (child as RibbonGroupBox); if (child != null) { string keys = KeyTip.GetKeys(child); if (keys != null) { // Gotcha! KeyTip keyTip = new KeyTip { Content = keys, Visibility = hide ? Visibility.Collapsed : Visibility.Visible }; // Add to list & visual // children collections keyTips.Add(keyTip); base.AddVisualChild(keyTip); associatedElements.Add(child); if (groupBox != null) { if (groupBox.State == RibbonGroupBoxState.Collapsed) { keyTip.Visibility = Visibility.Visible; FindKeyTips(child, true); continue; } else keyTip.Visibility = Visibility.Collapsed; } else { // Bind IsEnabled property Binding binding = new Binding("IsEnabled") { Source = child, Mode = BindingMode.OneWay }; keyTip.SetBinding(UIElement.IsEnabledProperty, binding); continue; } } if ((groupBox != null) && (groupBox.State == RibbonGroupBoxState.Collapsed)) { FindKeyTips(child, true); } else { FindKeyTips(child, hide); } } } }
// Find key tips on the given element private void FindKeyTips(UIElement element, bool hide) { this.Log("FindKeyTips"); IEnumerable children = LogicalTreeHelper.GetChildren(element); foreach (object item in children) { UIElement child = item as UIElement; RibbonGroupBox groupBox = (child as RibbonGroupBox); if (child != null) { string keys = KeyTip.GetKeys(child); if (keys != null) { // Gotcha! KeyTip keyTip = new KeyTip { Content = keys, Visibility = hide ? Visibility.Collapsed : Visibility.Visible }; // Add to list & visual // children collections keyTips.Add(keyTip); base.AddVisualChild(keyTip); associatedElements.Add(child); if (groupBox != null) { if (groupBox.State == RibbonGroupBoxState.Collapsed) { keyTip.Visibility = Visibility.Visible; FindKeyTips(child, true); continue; } else { keyTip.Visibility = Visibility.Collapsed; } } else { // Bind IsEnabled property Binding binding = new Binding("IsEnabled") { Source = child, Mode = BindingMode.OneWay }; keyTip.SetBinding(UIElement.IsEnabledProperty, binding); continue; } } if ((groupBox != null) && (groupBox.State == RibbonGroupBoxState.Collapsed)) { FindKeyTips(child, true); } else { FindKeyTips(child, hide); } } } }