コード例 #1
0
 /// <summary>
 /// Permet d'ajouter un séparateur à la CommandBar
 /// </summary>
 /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
 public static CommandBarElement AddSeparator(CommandBarEmplacement emplacement)
 {
     return AddObjectToCommandBar(CommandBarButtonType.Separator, emplacement, null, null, null, null, null);
 }
コード例 #2
0
 /// <summary>
 /// Ajoute un Toggle bouton à la CommandBar
 /// </summary>
 /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
 /// <param name="icon">Icon du bouton</param>
 /// <param name="label">Label du bouton</param>
 /// <param name="command">ICommand du bouton</param>
 /// <param name="commandParameter">CommandParameter de la ICommand du bouton</param>
 public static CommandBarElement AddToggleButton(CommandBarEmplacement emplacement, IconElement icon, string label,
     ICommand command, object commandParameter = null)
 {
     return AddObjectToCommandBar(CommandBarButtonType.ToggleButton, emplacement, icon, label, command, commandParameter, null);
 }
コード例 #3
0
 /// <summary>
 /// Ajoute un bouton avec un flyout associé à la CommandBar
 /// </summary>
 /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
 /// <param name="icon">Icon du bouton</param>
 /// <param name="label">Label du bouton</param>
 /// <param name="flyout">Flyout associé au bouton</param>
 public static CommandBarElement AddFlyoutButton(CommandBarEmplacement emplacement, IconElement icon, string label, FlyoutBase flyout)
 {
     return AddObjectToCommandBar(CommandBarButtonType.FlyoutButton, emplacement, icon, label, null, null, flyout);
 }
コード例 #4
0
        /// <summary>
        /// Ajoute un bouton à la barre
        /// </summary>
        /// <param name="objectType">type d'objet à créer</param>
        /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
        /// <param name="icon">Icon du bouton</param>
        /// <param name="label">Label du bouton</param>
        /// <param name="command">ICommand du bouton</param>
        /// <param name="commandParameter">CommandParameter de la ICommand du bouton</param>
        private static CommandBarElement AddObjectToCommandBar(CommandBarButtonType objectType, CommandBarEmplacement emplacement, IconElement icon, string label, ICommand command, object commandParameter, FlyoutBase flyout)
        {
            ICommandBarElement element = null;

            switch (objectType)
            {
                case CommandBarButtonType.Button:
                    element = new AppBarButton
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.ToggleButton:
                    element = new AppBarToggleButton()
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.FlyoutButton:
                    element = new AppBarButton()
                    {
                        Icon = icon,
                        Label = label,
                        Flyout = flyout
                    };
                    break;
                case CommandBarButtonType.Separator:
                    element = new AppBarSeparator();
                    break;
            }

            if (element != null)
            {
                if (emplacement == CommandBarEmplacement.Primary)
                {
                    _commandBar.PrimaryCommands.Add(element);
                }
                else
                {
                    _commandBar.SecondaryCommands.Add(element);
                }

                if (_commandBar.Visibility == Visibility.Collapsed)
                {
                    _commandBar.Visibility = Visibility.Visible;
                }
            }
            return new CommandBarElement() { Element = element, Emplacement = emplacement };
        }