当前位置: 首页>>代码示例>>C#>>正文


C# CollectionViewSource.DeferRefresh方法代码示例

本文整理汇总了C#中System.Windows.Data.CollectionViewSource.DeferRefresh方法的典型用法代码示例。如果您正苦于以下问题:C# CollectionViewSource.DeferRefresh方法的具体用法?C# CollectionViewSource.DeferRefresh怎么用?C# CollectionViewSource.DeferRefresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Data.CollectionViewSource的用法示例。


在下文中一共展示了CollectionViewSource.DeferRefresh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TaskListPage

        // Constructor
        public TaskListPage()
        {
            InitializeComponent();

            // trace data
            TraceHelper.AddMessage("TaskList: constructor");

            // set some data context information
            ConnectedIconImage.DataContext = App.ViewModel;
            SpeechProgressBar.DataContext = App.ViewModel;

            // set some data context information for the speech UI
            SpeechPopup_SpeakButton.DataContext = this;
            SpeechPopup_CancelButton.DataContext = this;
            SpeechLabel.DataContext = this;

            OrderedSource = new List<CollectionViewSource>();

            // add the name viewsource (which is a sorted view of the tasklist by name)
            var nameViewSource = new CollectionViewSource();
            using (nameViewSource.DeferRefresh())
            {
                nameViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending));
                nameViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
                OrderedSource.Add(nameViewSource);
                ByNameListBox.DataContext = this;
            }
            // add the due viewsource (which is a sorted view of the tasklist by due date)
            var dueViewSource = new CollectionViewSource();
            using (dueViewSource.DeferRefresh())
            {
                dueViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending));
                dueViewSource.SortDescriptions.Add(new SortDescription("DueSort", ListSortDirection.Ascending));
                dueViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
                OrderedSource.Add(dueViewSource);
                ByDueListBox.DataContext = this;
            }
            // add the priority viewsource (which is a sorted view of the tasklist by priority)
            var priViewSource = new CollectionViewSource();
            using (priViewSource.DeferRefresh())
            {
                priViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending));
                priViewSource.SortDescriptions.Add(new SortDescription("PriorityIDSort", ListSortDirection.Descending));
                priViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
                OrderedSource.Add(priViewSource);
                ByPriListBox.DataContext = this;
            }
            ImportTemplateViewSource = new CollectionViewSource();
            ImportTemplateViewSource.Filter += new FilterEventHandler(ImportTemplate_Filter);

            Loaded += new RoutedEventHandler(TaskListPage_Loaded);
            BackKeyPress += new EventHandler<CancelEventArgs>(TaskListPage_BackKeyPress);

            // trace data
            TraceHelper.AddMessage("Exiting TaskList constructor");
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:57,代码来源:TaskListPage.xaml.cs

示例2: UpdateIncrementalSearch

		void UpdateIncrementalSearch(TextBox textBox, CollectionViewSource collectionViewSource, ref FilterEventHandler oldFilter)
		{
			var text = textBox.Text.Split(' ', ' ');

			using (collectionViewSource.DeferRefresh())
			{
				FilterEventHandler newFilter = (sender2, e2) =>
					e2.Accepted = e2.Accepted && (!text.Any() || e2.Item.TypeMatch
					(
						(FollowManagerWindowViewModel.Follow _) => new[] { _.User.Name, _.User.FullName, _.User.Description },
						(User _) => new[] { _.Name, _.FullName, _.Description },
						_ => Enumerable.Empty<string>()
					)
					.Where(_ => _ != null)
					.Any(_ => text.All(_.Contains)));

				collectionViewSource.Filter += newFilter;

				if (oldFilter != null)
					collectionViewSource.Filter -= oldFilter;

				oldFilter = newFilter;
			}
		}
开发者ID:karno,项目名称:OpenSolar,代码行数:24,代码来源:FollowManagerWindow.xaml.cs

示例3: GroupsAreRecreated

		public void GroupsAreRecreated ()
		{
			Func<object, object, bool> nameMatcher = (groupName, itemName) => (string) groupName == (string) itemName;
			Func<object, int, CultureInfo, object> nameCreator = (item, level, culture) => ((int) item <= 2 ? "Lower" : "Upper") + level.ToString ();

			var desc = new ConcretePropertyGroupDescription () {
				GroupNameFromItemFunc = nameCreator,
				NamesMatchFunc = nameMatcher
			};

			var source = new CollectionViewSource { Source = new [] { 0, 1, 2, 3, 4, 5 } };
			source.GroupDescriptions.Add (desc);

			var groups = source.View.Groups;
			var lowerGroup = (CollectionViewGroup) source.View.Groups [0];
			var upperGroup = (CollectionViewGroup) source.View.Groups [1];


			using (source.DeferRefresh ())
			using (source.View.DeferRefresh ()) {
				source.GroupDescriptions.Clear ();
				source.GroupDescriptions.Add (desc);
			}

			Assert.AreSame (groups, source.View.Groups, "#1");
			Assert.AreNotSame (lowerGroup, source.View.Groups [0], "#2");
			Assert.AreNotSame (upperGroup, source.View.Groups [1], "#3");
		}
开发者ID:shana,项目名称:moon,代码行数:28,代码来源:CollectionViewGroupTest.cs

示例4: DocumentsPageModel

        public DocumentsPageModel()
		{
			ModelUrl = "/documents";
		
			ApplicationModel.Current.Server.Value.RawUrl = null;
            SelectedCollectionSortingMode = new Observable<string> { Value = Settings.Instance.CollectionSortingMode };

            collectionSource = new CollectionDocumentsCollectionSource();
            collectionDocumentsModel = new DocumentsModel(collectionSource)
            {
                DocumentNavigatorFactory = (id, index) =>
                                           DocumentNavigator.Create(id, index, CollectionsIndex,
                                                                    new IndexQuery
                                                                    {
                                                                        Query = "Tag:" + GetSelectedCollectionName()
                                                                    })
            };
            collectionDocumentsModel.SetChangesObservable(d => d.IndexChanges
                     .Where(n => n.Name.Equals(CollectionsIndex, StringComparison.InvariantCulture))
                     .Select(m => Unit.Default));

            allDocumentsDocumentsModel = new DocumentsModel(new DocumentsCollectionSource())
            {
                DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index),
                Context = "AllDocuments",
            };

            allDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default));

			ravenDocumentsDocumentsModel = new DocumentsModel(new CollectionDocumentsCollectionSource());

			ravenDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default));

            Collections = new BindableCollection<CollectionModel>(model => model.Name)
            {
                new AllDocumentsCollectionModel(),
				new RavenDocumentsCollectionModel()
            };

            SelectedCollection = new Observable<CollectionModel>();
            SelectedCollection.PropertyChanged += (sender, args) =>
            {
                PutCollectionNameInTheUrl();

                var selectedCollectionName = GetSelectedCollectionName();
                if (selectedCollectionName == "")
                {
                    DocumentsModel = allDocumentsDocumentsModel;
                }
				else if (selectedCollectionName == "Raven Documents")
				{
					DocumentsModel = ravenDocumentsDocumentsModel;
				}
                else
                {
                    collectionSource.CollectionName = selectedCollectionName;
                    collectionDocumentsModel.Context = "Collection/" + GetSelectedCollectionName();
                    DocumentsModel = collectionDocumentsModel;
                }
            };

		    SortedCollectionsList = new CollectionViewSource
		    {
		        Source = Collections,
		        SortDescriptions =
		        {
					GetSortDescription()
		        }
		    };

            SelectedCollectionSortingMode.PropertyChanged += (sender, args) =>
			{
			    using (SortedCollectionsList.DeferRefresh())
			    {
			        SortedCollectionsList.SortDescriptions.Clear();
			        SortedCollectionsList.SortDescriptions.Add(GetSortDescription());
			    }

				Settings.Instance.CollectionSortingMode = SelectedCollectionSortingMode.Value;
			};

            CollectionsListWidth = DefaultCollectionsListWidth;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:83,代码来源:DocumentsPageModel.cs


注:本文中的System.Windows.Data.CollectionViewSource.DeferRefresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。