Example #1
0
 public void Dispose()
 {
     BindingOperations.ClearBinding(this, EnumTypeProperty);
     BindingOperations.ClearBinding(this, FilterPropertiesProperty);
     ItemsList        = null;
     FilterProperties = null;
 }
Example #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (Template != null)
            {
                var closeCommand = isPrimaryFilter ? mainModel.CloseSubFilterCommand : mainModel.CloseAdditionalFilterCommand;
                MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement;
                if (MenuHost != null)
                {
                    MenuHost.InputBindings.Add(new KeyBinding(closeCommand, new KeyGesture(Key.Back)));
                    MenuHost.InputBindings.Add(new KeyBinding(closeCommand, new KeyGesture(Key.Escape)));
                    MenuHost.InputBindings.Add(new XInputBinding(closeCommand, XInputButton.B));
                }

                ButtonBack = Template.FindName("PART_ButtonBack", this) as ButtonBase;
                if (ButtonBack != null)
                {
                    ButtonBack.Command = closeCommand;
                }

                ButtonClear = Template.FindName("PART_ButtonClear", this) as ButtonBase;
                if (ButtonClear != null)
                {
                    ButtonClear.Command = new RelayCommand <object>(a =>
                    {
                        FilterProperties = null;
                        IgnoreChanges    = true;
                        ItemsList?.ForEach(b => b.Selected = false);
                        IgnoreChanges = false;
                    });
                    BindingTools.SetBinding(ButtonClear,
                                            FocusBahaviors.FocusBindingProperty,
                                            mainModel,
                                            nameof(mainModel.SubFilterVisible));
                }

                ItemsHost = Template.FindName("PART_ItemsHost", this) as ItemsControl;
                if (ItemsHost != null)
                {
                    FilterDbItemtSelection.AssignItemListPanel(ItemsHost);
                    BindingTools.SetBinding(
                        ItemsHost,
                        ItemsControl.ItemsSourceProperty,
                        this,
                        nameof(ItemsList));
                }
            }
        }
        private void NewItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (IgnoreChanges)
            {
                return;
            }

            if (e.PropertyName == nameof(SelectableItem <SelectionObject> .Selected))
            {
                var selected = ItemsList.Where(a => a.Selected == true);
                if (selected.HasItems())
                {
                    FilterProperties = new EnumFilterItemProperites(selected.Select(a => a.Item.Value).ToList());
                }
                else
                {
                    FilterProperties = null;
                }
            }
        }
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     FilterProperties = null;
 }
 public override void ClearButtonAction(RoutedEventArgs e)
 {
     FilterProperties = null;
 }