void AddKeyBindings(Window win, MenuItemCollectionViewModel items) { foreach (var item in items) { if (item.Command != null) { if (item.KeyGesture != null) { win.InputBindings.Add(new KeyBinding(item.Command, item.KeyGesture) { CommandParameter = item.CommandParameter }); } } if (item._items != null) { AddKeyBindings(win, item._items); } } }