protected FilterTreeViewModel(IFilterTreeModelPageSpecificSettings settings, IQueryable <TEntity> entities, Action <object, Action> registerEntityChangedMessageHandler) { this.settings = settings; this.entities = entities; StaticFilters = CreateFilterItems(settings.StaticFilters); CustomFilters = CreateFilterItems(settings.CustomFilters); SelectedItem = StaticFilters.FirstOrDefault(); AllowFiltersContextMenu = true; WarningParameterName = "Overdue Tasks"; ShowFilterGroup = true; Messenger.Default.Register <EntityMessage <TEntity, TPrimaryKey> >(this, message => UpdateFilters()); // temporary fix Messenger.Default.Register <CreateCustomFilterMessage <TEntity> >(this, message => { CreateCustomFilter((message as CreateCustomFilterMessage <TEntity>).Module); }); UpdateFilters(); StaticCategoryName = settings.StaticFiltersTitle; CustomCategoryName = settings.CustomFiltersTitle; Categories = new ObservableCollection <FilterCategory>() { new FilterCategory(StaticCategoryName, this, StaticFilters), new FilterCategory(CustomCategoryName, this, CustomFilters, isCustom: true) }; }
protected FilterTreeViewModel(IFilterTreeModelPageSpecificSettings settings, IQueryable <TEntity> entities, Action <object, Action> registerEntityChangedMessageHandler) { this.settings = settings; this.entities = entities; StaticFilters = CreateFilterItems(settings.StaticFilters); CustomFilters = CreateFilterItems(settings.CustomFilters); SelectedItem = StaticFilters.FirstOrDefault(); registerEntityChangedMessageHandler(this, () => UpdateFilters()); Messenger.Default.Register <CreateCustomFilterMessage <TEntity> >(this, message => CreateCustomFilter()); UpdateFilters(); StaticCategoryName = settings.StaticFiltersTitle; }
protected FilterTreeViewModel(IFilterTreeModelPageSpecificSettings <TFilterEntity> settings, IQueryable <TEntity> entities, Action <object, Action> registerEntityChangedMessageHandler, bool createContextFilter = false) { this.settings = settings; this.entities = entities; StaticFilters = CreateFilterItems(settings.StaticFilters, false); CustomFilters = CreateFilterItems(settings.CustomFilters, true); if (createContextFilter) { ContextFilters = CreateContextFilterItems(); } SelectedItem = StaticFilters.FirstOrDefault(); if (SelectedItem != null) { SelectedItem.IsSelected = true; } registerEntityChangedMessageHandler(this, () => UpdateFilters()); Messenger.Default.Register <CreateCustomFilterMessage <TEntity> >(this, message => CreateCustomFilter()); UpdateFilters(); StaticCategoryName = settings.StaticFiltersTitle; ContextCategoryName = typeof(TFilterEntity).Name; CustomCategoryName = "CUSTOM FILTERS"; //Instead of putting it in xaml, use binding to ensure that code behind indeed exists to show anything in view }
public virtual void Init() { StaticFilters = CreateFilterItems(settings.StaticFilters); CustomFilters = CreateFilterItems(settings.CustomFilters); SelectedItem = StaticFilters.FirstOrDefault(); }