protected virtual CustomLookUpOptPopupContent CreateWindow() { var destType = typeof(IListViewModel <>).MakeGenericType(LookupInfo.ItemType); var model = (IObjectListViewModel)IoC.Instance.Resolve(destType, null); model.Mode = ObjectListMode.LookUpList3Points; model.AllowAddNew = true; model.InitializeMenus(); //model.IsFilterVisible = true; var modelCapt = model as PanelViewModelBase; if (modelCapt != null) { modelCapt.SetPanelCaptionPrefix(DataContext.GetType()); modelCapt.IsActive = true; } if (EditValue != null) { model.ValueMember = GetValueMember(); model.EditValue = EditValue; } // выставляем ограничения на кол-во строк if (model.CustomFilters != null) { model.CustomFilters.MaxRowCount = MaxFetchItemsCount; model.CustomFilters.FilterExpression = "NONE"; model.CustomFilters.SqlFilterExpression = FilterInternal; if (!string.IsNullOrEmpty(FilterInternal)) //Внимание. Метод зависит от наличия меню - model.InitializeMenus { model.ChangeImageFilter(false); } } // если у нас уже нафильтровано какое-то кол-во значений - отдаем их в форму if (ItemsSource != null) { var items = ItemsSource.Clone(); if (items is IList) { foreach (var item in ((IList)items).OfType <EditableBusinessObject>()) { item.AcceptChanges(); } } model.SetSource(items); //model.CustomFilters.FilterExpression = FilterInternal; } else // иначе лезем в БД за данными для "..." { model.ApplyFilter(); } var result = new CustomLookUpOptPopupContent { DataContext = model, }; if (result.Owner == null && Application.Current.MainWindow.IsActive) { result.Owner = Application.Current.MainWindow; } return(result); }