Exemplo n.º 1
0
        /// <summary>
        /// Populates the current ribbon with items based on the actions collection
        /// </summary>
        protected virtual void PopulateStack()
        {
            var          actions    = Model as IHaveActions;
            var          viewResult = SelectedView as ViewResult;
            IHaveActions actions2   = null;

            if (viewResult != null)
            {
                actions2 = viewResult.Model as IHaveActions;
            }

            Children.Clear();
            if (actions == null)
            {
                Visibility = Visibility.Collapsed;
                return;
            }
            Visibility = Visibility.Visible;

            var actionList = ViewActionHelper.GetConsolidatedActions(actions, actions2);

            foreach (var action in actionList)
            {
                var button = new ViewActionStackPanelButton {
                    Command = action, ToolTip = action.Caption, DataContext = action
                };
                if (ActionFilter == ViewActionStackPanelActionFilter.ShowPinned)
                {
                    button.SetBinding(VisibilityProperty, new MultiBinding
                    {
                        Bindings =
                        {
                            new Binding("Visibility"),
                            new Binding("IsPinned")
                        },
                        Converter = new VisibilityAndPinnedConverter()
                    });
                }
                else
                {
                    button.SetBinding(VisibilityProperty, new Binding("Visibility"));
                }
                var action2 = action as ViewAction;
                if (action2 != null)
                {
                    var rectangle = new Rectangle {
                        Fill = action2.PopulatedBrush
                    };
                    button.Content = rectangle;
                }
                Children.Add(button);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populates the current ribbon with items based on the actions collection
        /// </summary>
        private void PopulateStack()
        {
            var actions = Model as IHaveActions;
            var viewResult = SelectedView as ViewResult;
            IHaveActions actions2 = null;
            if (viewResult != null) actions2 = viewResult.Model as IHaveActions;

            Children.Clear();
            if (actions == null)
            {
                Visibility = Visibility.Collapsed;
                return;
            }
            Visibility = Visibility.Visible;

            var actionList = ViewActionHelper.GetConsolidatedActions(actions, actions2);
            foreach (var action in actionList)
            {
                var button = new ViewActionStackPanelButton {Command = action, ToolTip = action.Caption, DataContext = action};
                if (ActionFilter == ViewActionStackPanelActionFilter.ShowPinned)
                    button.SetBinding(VisibilityProperty, new MultiBinding
                    {
                        Bindings =
                        {
                            new Binding("Visibility"),
                            new Binding("IsPinned")
                        },
                        Converter = new VisibilityAndPinnedConverter()
                    });
                else
                    button.SetBinding(VisibilityProperty, new Binding("Visibility"));
                var action2 = action as ViewAction;
                if (action2 != null)
                {
                    var rectangle = new Rectangle {Fill = action2.PopulatedBrush};
                    button.Content = rectangle;
                }
                Children.Add(button);
            }
        }