Пример #1
0
        /// <summary>
        /// Handles changes to the ParentCollection property.
        /// </summary>
        private static void OnParentCollectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CityFilter             target = (CityFilter)d;
            IEnumerable <CityItem> oldParentCollection = (IEnumerable <CityItem>)e.OldValue;

            if (target.filterPresenter != null)
            {
                bool isActive = target.IsActive;
                if (isActive)
                {
                    target.IsActive = false;
                }
                target.filterPresenter.ReceiveFilterChanged(target);
                if (isActive)
                {
                    target.IsActive = true;
                }
            }
            IEnumerable <CityItem> newParentCollection = target.ParentCollection;

            target.filterPresenter = FilterPresenter.TryGet(newParentCollection);
            if (target.filterPresenter != null)
            {
                target.filterPresenter.ReceiveFilterChanged(target);
            }
            target.OnParentCollectionChanged(oldParentCollection, newParentCollection);
        }
Пример #2
0
        public CategoryFilterView()
        {
            InitializeComponent();
            // Define Filter that must be use.
            EqualFilterInitializer initializer = new EqualFilterInitializer();
            // Get FilterPresenter that connected to default collection view for Workspace.This.Products collection.
            FilterPresenter productsCollectionViewFilterPresenter = FilterPresenter.TryGet(Workspace.This.Products);
            // Get EqualFilter that use Category item property.
            EqualFilter filter = ((EqualFilter)(productsCollectionViewFilterPresenter.TryGetFilter("Category", initializer)));

            // Use instance of EqualFilter as Model.
            Model = filter;
        }
Пример #3
0
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            OrdersVm vm = e.NewValue as OrdersVm;

            if (vm != null)
            {
                FilterPresenter fpr = FilterPresenter.TryGet(vm.OrdersCollectionView);
                filter = fpr.TryGetFilter("Employee", new EqualFilterInitializer());
                if (filter != null)
                {
                    if (filter.IsActive)
                    {
                        VisualStateManager.GoToState(this, "Filtered", false);
                    }
                    else
                    {
                        VisualStateManager.GoToState(this, "Unfiltered", false);
                    }
                    filter.PropertyChanged += filter_PropertyChanged;
                }
            }
        }