I am putting some custom controls, e.g. drop down buttons, custom menu items, none of them are inherited from any Tool button. When I press Alt to access their key tip, seems like they have been automatically assign.
Q1: how can i change the key tip content?
Q2: when i press a key tip for a custom drop down, it can be only be focused. How can i interfere with the behavior to make the drop down open?
Thanks, Nathan
I can manage to open the drop down and set my custom KeyTip, but still have 1 issue:
I have another custom control (like MenuItemEx) in my drop down, how can i set key tip onto those MenuItemEx?
I found an interface IKeyTip, but failed to add KeyTip to it.
Any ideas please?
Thanks,
Nathan
Hello Nathan,
Can you possibly send a small sample that can reproduce your problem?
Thank you,
Mihoko Kamiishi
Examples:
<igRibbon:XamRibbon.Tabs> <igRibbon:RibbonTabItem Header="Shared_Tab_Format_Header"> <igRibbon:RibbonGroup VerticalAlignment="Top" Caption="Shared_Tab_Format_Group_GlobalFont_Caption" Id="FontGlobal"> <StackPanel Margin="0,0,0,0" VerticalAlignment="Top" Orientation="Horizontal"> <ns:MenuButton igRibbon:RibbonGroup.MaximumSize="ImageOnly" igRibbon:RibbonToolHelper.KeyTip="CC" ButtonType="Segmented">
<igRibbon:MenuTool.SmallImage> <BitmapImage UriSource="/WpfApplication2;component/Resources/rebalance_session_16.png" /> </igRibbon:MenuTool.SmallImage> <ns:MenuItemEx Header="Hello" IsCheckable="True" /> <ns:MenuItemEx Header="Hello1" /> <ns:MenuItemEx Header="Hello2" InputGestureText="CTRL+R"/> </ns:MenuButton> <igRibbon:LabelTool x:Name="lb" HorizontalAlignment="Right" Caption="Good!" /> </StackPanel> </igRibbon:RibbonGroup> </igRibbon:RibbonTabItem> </igRibbon:XamRibbon.Tabs>
Indeed, ns:MenuItemEx is my a control inherited from MenuItem, IKeyTip.
ns:MenuButton is a menu button which is inherited from ItemsControl and IKeyTipContainer. The drop down which contains MenuItemEx will show up after pressing 'CC', achieved by codes below:
public IKeyTip[] GetKeyTips() { var keyTips = new List<IKeyTip>(); if (Items.Count == 0) return keyTips.ToArray();
foreach (var sub in Items) { var keyTip = sub as IKeyTip; if (keyTip == null) continue;
keyTips.Add(keyTip); }
_dropdownPopup.IsOpen = true; return keyTips.ToArray(); }
but after pop up showing up, there is no key tip for MenuItemEx at all.
Let me know if any questions.
Hello Nathan, Thank you for the code.
I'm currently looking into this.I will let you know when I have an update. Thank you, Mihoko Kamiishi
hi, expert,
Thanks a lot. This is perfect!
That's exactly what I want. I really appreciate your efforts and it means a lot to me.
Best Regards,
It seems that you need to return true in IKeyTip’s Activate() method in order to show a keytip on the sub menu items.
I have updated the sample to add another level of items to the custom menu.I modified some methods from IKeyTipContainer and IKeyTip there following the implementation of MenuToolBase.cs and ToolMenuItem.cs.
Thank you,Mihoko Kamiishi
Thanks a lot.
really appreciate that and it's a perfect answer for me.
But still got 1 question need to address out: how to deal with the multi-level menu items. I add another level of items to a sub menu item, and add some logic to get sub menu opened, but it cannot show anything key tip at all.
Code to active sub menu:
bool IKeyTip.Activate() { if (Items.Count > 0) { IsSubmenuOpen = true; return false; }
RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent)); return true; }
Any suggestions or examples please?
I have attached the sample that shows a keytip on a custom control implementing IKeyTip interface.
MenuItemEx here is the class implements MenuItem and IKeyTip.