private void SetFilter(Point position, Type type, string tittlefieldName, string bindPath)
        {
            if (this.ItemsSource != null)
            {
                var dv = this.ItemsSource as DataView;

                if (dv != null)
                {
                    FilterDescription filter = new FilterDescription {
                        type = type, tittlefieldName = tittlefieldName, fieldName = bindPath, comparison = "=", value = SelectedText(bindPath)
                    };
                    this.activeFilters.Add(filter);

                    FiltersInput fmFiltersInput = new FiltersInput(this.activeFilters);
                    fmFiltersInput.Owner = Application.Current.MainWindow;

                    if (fmFiltersInput.Demonstrate(position) == true)
                    {
                        this.SetRowFilter();
                    }

                    if (this.Items.Count > 0)
                    {
                        this.SelectedIndex = 0;
                    }
                }
            }
        }
示例#2
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item == null)
            {
                return(null);
            }

            if (container as FrameworkElement != null)
            {
                bool Founded = false;
                FilterDescription filterDescription = (FilterDescription)item;
                DataTemplate      dataTemplate      = null;

                if ((Type)filterDescription.type == typeof(string))
                {
                    string templateName = "stringFilterTemplate";
                    if (_extension.TemplateDictionary.ContainsKey(templateName))
                    {
                        Founded = (_extension.TemplateDictionary.TryGetValue(templateName, out dataTemplate));
                    }
                }

                if ((Type)filterDescription.type == typeof(DateTime))
                {
                    string templateName = "dateFilterTemplate";
                    if (_extension.TemplateDictionary.ContainsKey(templateName))
                    {
                        Founded = (_extension.TemplateDictionary.TryGetValue(templateName, out dataTemplate));
                    }
                }

                if (Founded)
                {
                    return(dataTemplate);
                }
            }

            return(null);
        }