public MoveCurrentToPosition ( int position ) : bool | ||
position | int | |
Результат | bool |
public ChangeCarParentDialog(CarObject car) { InitializeComponent(); DataContext = this; Buttons = new[] { OkButton, CreateExtraDialogButton(ControlsStrings.CarParent_MakeIndependent, () => { Car.ParentId = null; Close(); }), CancelButton }; Car = car; Filter = car.Brand == null ? "" : @"brand:" + car.Brand; CarsListView = new ListCollectionView(CarsManager.Instance.LoadedOnly.Where(x => x.ParentId == null && x.Id != Car.Id).ToList()) { CustomSort = this }; UpdateFilter(); if (car.Parent == null) { CarsListView.MoveCurrentToPosition(0); } else { CarsListView.MoveCurrentTo(car.Parent); } Closing += CarParentEditor_Closing; }
public CustomerListModel(List<Customer> data) { _data = data; _customers = (ListCollectionView) CollectionViewSource.GetDefaultView(_data); _customers.Filter = FilterCustomers; _customers.CurrentChanged += CustomerChanged; _customers.CustomSort = new CustomerSorter(); _customers.MoveCurrentToPosition(-1); }
public AccountTransactionViewModel(IFileProcessorFactory processorFactory, IViewThreadExecutor viewThreadExecutor, IDataService dataService, IAccTransactionValidator validator) { var processorTable = processorFactory.ProcessorNames.ToDictionary(x => x, x => processorFactory.GetFileProcessor(x)); var details = processorFactory .ProcessorNames .Select(x => { var fileProcessor = processorFactory.GetFileProcessor(x); var allFileDetails = fileProcessor.GetAllFileNames() .Select(fileName => new FileDetailViewModel(fileName, dataService, viewThreadExecutor, fileProcessor, validator)) .ToArray(); return new ProcessorDetails(x, allFileDetails); }).ToList(); ProcessorDetails = new ListCollectionView(details); if(details.Count > 0) ProcessorDetails.MoveCurrentToPosition(0); }
public static ListCollectionView GetSitesView(OnlineVideosMainWindow window, string preselectedSiteName = null) { int? indexToSelect = null; List<Site> convertedSites = new List<Site>(); int i = 0; foreach (var s in OnlineVideos.OnlineVideoSettings.Instance.SiteUtilsList.Values) { if (preselectedSiteName != null && s.Settings.Name == preselectedSiteName) indexToSelect = i; convertedSites.Add(new Site(s)); i++; } ListCollectionView view = new ListCollectionView(convertedSites) { Filter = new Predicate<object>(s => ((ViewModels.Site)s).Name.ToLower().Contains(window.CurrentFilter)), }; if (indexToSelect != null) view.MoveCurrentToPosition(indexToSelect.Value); return view; }
/// <summary> /// Create a new instance of <see cref="WorkspaceViewModel"/> /// </summary> public WorkspaceViewModel() { ToggleControl = new DelegateCommand<UIElement>(this.OnToggleControl); AddWorkspaceCommand = new DelegateCommand<TextBox>( this.OnAddWorkspaceCommand); RemoveWorkspaceCommand = new DelegateCommand( this.OnRemoveWorkspaceCommand); OpenWorkspace = new DelegateCommand( this.OnOpenWorkspace); ObservableCollection<WorkspaceModel> data = new ObservableCollection<WorkspaceModel>( service.Load()); CurrentWorkspaces = new ListCollectionView( data); CurrentWorkspaces.MoveCurrentToPosition(-1); CurrentWorkspaces.CurrentChanged += CurrentWorkspaces_CurrentChanged; }
public static ListCollectionView GetCategoriesView(OnlineVideosMainWindow window, IList<OnlineVideos.Category> categories, string preselectedCategoryName = null) { int? indexToSelect = null; List<Category> convertedCategories = new List<Category>(); int i = 0; if (categories != null) { foreach (var c in categories) { if (preselectedCategoryName != null && c.Name == preselectedCategoryName) indexToSelect = i; convertedCategories.Add(new Category(c)); i++; } } ListCollectionView view = new ListCollectionView(convertedCategories) { Filter = new Predicate<object>(cat => (((Category)cat).Name ?? "").ToLower().Contains(window.CurrentFilter)) }; if (indexToSelect != null) view.MoveCurrentToPosition(indexToSelect.Value); return view; }