Пример #1
0
        /// <summary>
        ///     Called when [apply template].
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Get the stackpanel from the template so we can populate its contents with the
            // provided actions.
            TheStackPanel = GetTemplateChild("TheStackPanel") as StackPanel;
            foreach (AppBarMenuAction action in _theActions)
            {
                action.Parent = this;
                var menuItem = new AppBarMenuItem
                {
                    Content    = action.Content,
                    Command    = action.Command,
                    Foreground = Foreground
                };

                if (TheStackPanel != null)
                {
                    TheStackPanel.Children.Add(menuItem);
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Called when [apply template].
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Get the stackpanel from the template so we can populate its contents with the 
            // provided actions.
            TheStackPanel = GetTemplateChild("TheStackPanel") as StackPanel;
            foreach (AppBarMenuAction action in _theActions)
            {
                action.Parent = this;
                var menuItem = new AppBarMenuItem
                    {
                        Content = action.Content,
                        Command = action.Command,
                        Foreground = Foreground
                    };

                if (TheStackPanel != null) 
                    TheStackPanel.Children.Add(menuItem);
            }
        }