Esempio n. 1
0
        private static void RepopulateItems(ActionItemsControl itemsControl, IHaveActions actionHost)
        {
            itemsControl.Visibility = Visibility.Visible;

            // We also need to hook all actions' changed event so we can update this view whenever the availability changes
            foreach (var inpc in actionHost.Actions.OfType <INotifyPropertyChanged>())
            {
                inpc.PropertyChanged += (s, a) =>
                {
                    if (a.PropertyName == "Availability")
                    {
                        RepopulateItems(itemsControl, actionHost);
                    }
                }
            }
            ;

            // Getting all currently available actions
            var actions = actionHost.Actions.Where(a => a.Availability == ViewActionAvailabilities.Available).OrderBy(a => a.CategoryOrder).ToList();

            if (itemsControl.ViewActionPolicy != null)
            {
                actions = itemsControl.ViewActionPolicy.ProcessActions(actions).ToList();
            }
            itemsControl.ItemsSource = itemsControl.OnRepopulateItems(actions);
        }
Esempio n. 2
0
        private static void RepopulateItems(ActionItemsControl itemsControl, IHaveActions actionHost)
        {
            itemsControl.Visibility = Visibility.Visible;

            // We also need to hook all actions' changed event so we can update this view whenever the availability changes
            foreach (var inpc in actionHost.Actions.OfType<INotifyPropertyChanged>())
                inpc.PropertyChanged += (s, a) =>
                                            {
                                                if (a.PropertyName == "Availability")
                                                    RepopulateItems(itemsControl, actionHost);
                                            };

            // Getting all currently available actions
            var actions = actionHost.Actions.Where(a => a.Availability == ViewActionAvailabilities.Available).OrderBy(a => a.CategoryOrder).ToList();
            itemsControl.ItemsSource = itemsControl.OnRepopulateItems(actions);
        }