public static AppBarButtonContainer ToAppBarButtonContainer(this IContextMenu source, bool isSecondary)
        {
            var menu = new AppBarButtonContainer();
            var commandsVector = isSecondary ? menu.SecondaryCommands : menu.PrimaryCommands;
            commandsVector.Clear();

            foreach (var item in source.Items)
            {
                AppBarButton button = new AppBarButton();
                commandsVector.Add(button);
                button.Label = item.Header;
                button.Command = item.Command;
                button.CommandParameter = item.CommandParameter;

                if (!string.IsNullOrEmpty(item.Icon))
                {
                    var icon = new SymbolIcon();
                    icon.Symbol = (Symbol)System.Enum.Parse(typeof(Symbol), item.Icon);
                    button.Icon = icon;
                }
                else
                    button.Icon = new SymbolIcon(Symbol.Emoji);
            }

            return menu;
        }
Esempio n. 2
0
        private void SelectBottomAppBar(AppBarButtonContainer container)
        {
            try
            {
                CommandBar bottomBar = this.BottomAppBar as CommandBar;
                bottomBar.PrimaryCommands.Clear();
                bottomBar.SecondaryCommands.Clear();

                foreach (ICommandBarElement item in container.PrimaryCommands)
                    bottomBar.PrimaryCommands.Add(item);

                foreach (ICommandBarElement item in container.SecondaryCommands)
                    bottomBar.SecondaryCommands.Add(item);
            }
            catch (Exception) { }
        }