private void getGestures( MenuItem item, Dictionary< KeyGesture, MenuItem > map ) { if (item.Gesture != null) map.Add( item.Gesture, item ); if ( item.Type == MenuItemType.RootSubmenu || item.Type == MenuItemType.Submenu ) { foreach ( MenuItemBase itemBase in item.Items ) { if ( itemBase is MenuItem ) { getGestures( ( MenuItem ) itemBase, map ); } } } }