/// <summary> /// Create model for FilterControl, if it is possible in current state. /// </summary> /// <returns>Instance of FilterControlVm or null.</returns> protected virtual FilterControlVm CreateModel() { FilterControlVm vm = null; filterPresenter = Parent == null ? null : FilterPresenter.TryGet(ParentCollection); if (filterPresenter != null) { vm = filterPresenter.TryGetFilterControlVm(Key, FilterInitializersManager); } return(vm); }
/// <summary> /// Initializes the filter view model. /// </summary> protected override FilterControlVm CreateModel() { FilterControlVm vm = null; filterPresenter = Parent == null ? null : FilterPresenter.TryGet(ParentCollection); if (filterPresenter != null) { if (Key == null) { DataGridColumnHeader columnHeader = this.GetParent <DataGridColumnHeader>(); if (columnHeader == null) { return(null); } DataGridColumn column = columnHeader.Column; if (column == null) { return(null); } DataGrid dataGrid = columnHeader.GetParent <DataGrid>(); if (dataGrid == null) { return(null); } if (column.DisplayIndex >= dataGrid.Columns.Count) { return(null); } IEnumerable <FilterInitializer> initializers = GetInitializers(column) ?? FilterInitializersManager; string key = Key ?? GetColumnKey(column); vm = filterPresenter.TryGetFilterControlVm(key, initializers); } else { IEnumerable <FilterInitializer> initializers = FilterInitializersManager; vm = filterPresenter.TryGetFilterControlVm(Key, initializers); } if (vm != null) { vm.IsEnable = true; } } return(vm); }