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


C# ICollectionView.DeferRefresh方法代码示例

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


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

示例1: SortViewModel

        public SortViewModel(ICollectionView source, SortData[] columns, IEnumerable<SortDescription> existing = null,
            SortData[] requiredColumns = null) {
            View = source;
            Columns = columns;
            _requiredColumns = requiredColumns ?? new SortData[0];
            if (existing != null) {
                var d = View.DeferRefresh();
                SortDescriptions.Clear();
                foreach (var c in _requiredColumns)
                    SortDescriptions.Add(c.ToSortDescription());
                var item = existing
                    .FirstOrDefault(x => Columns.Select(y => y.Value).Contains(x.PropertyName));
                if (item != default(SortDescription)) {
                    SelectedSort = Columns.First(x => x.Value == item.PropertyName);
                    SelectedSort.SortDirection = item.Direction;
                    SortDescriptions.Add(item);
                }

                d.Dispose();
            } else {
                var item = SortDescriptions.FirstOrDefault(x => Columns.Select(y => y.Value).Contains(x.PropertyName));
                if (item != default(SortDescription)) {
                    SelectedSort = Columns.First(x => x.Value == item.PropertyName);
                    SelectedSort.SortDirection = item.Direction;
                }
            }

            OldSelectedSort = SelectedSort;

            this.WhenAnyValue(x => x.SelectedSort)
                .Skip(1)
                .Subscribe(x => SortColumn());
            this.SetCommand(x => x.SortCommand).Subscribe(x => SortColumn());
            this.SetCommand(x => x.ToggleVisibilityCommand).Subscribe(x => ToggleVisibility());
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:35,代码来源:SortViewModel.cs

示例2: Sort

        private static ICollectionView Sort( ICollectionView view, string propertyName, ListSortDirection direction, bool append )
        {
            Contract.Requires( view != null, "view" );
            Contract.Requires( !string.IsNullOrEmpty( propertyName ), "propertyName" );
            Contract.Ensures( Contract.Result<ICollectionView>() != null );
            using ( var defer = view.DeferRefresh() )
            {
                if ( !append )
                    view.SortDescriptions.Clear();

                view.SortDescriptions.Add( new SortDescription( propertyName, direction ) );
            }

            return view;
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:15,代码来源:ICollectionViewExtensions.cs

示例3: ApplyPropertiesToView

        // Forward properties from the CollectionViewSource to the CollectionView
        void ApplyPropertiesToView(ICollectionView view)
        {
            if (view == null || _deferLevel > 0)
                return;

            ICollectionViewLiveShaping liveView = view as ICollectionViewLiveShaping;

            using (view.DeferRefresh())
            {
                int i, n;

                // Culture
                if (Culture != null)
                {
                    view.Culture = Culture;
                }

                // Sort
                if (view.CanSort)
                {
                    view.SortDescriptions.Clear();
                    for (i=0, n=SortDescriptions.Count;  i < n;  ++i)
                    {
                        view.SortDescriptions.Add(SortDescriptions[i]);
                    }
                }
                else if (SortDescriptions.Count > 0)
                    throw new InvalidOperationException(SR.Get(SRID.CannotSortView, view));

                // Filter
                Predicate<object> filter;
                if (FilterHandlersField.GetValue(this) != null)
                {
                    filter = FilterWrapper;
                }
                else
                {
                    filter = null;
                }

                if (view.CanFilter)
                {
                    view.Filter = filter;
                }
                else if (filter != null)
                    throw new InvalidOperationException(SR.Get(SRID.CannotFilterView, view));

                // GroupBy
                if (view.CanGroup)
                {
                    view.GroupDescriptions.Clear();
                    for (i=0, n=GroupDescriptions.Count;  i < n;  ++i)
                    {
                        view.GroupDescriptions.Add(GroupDescriptions[i]);
                    }
                }
                else if (GroupDescriptions.Count > 0)
                    throw new InvalidOperationException(SR.Get(SRID.CannotGroupView, view));

                // Live shaping
                if (liveView != null)
                {
                    ObservableCollection<string> properties;

                    // sorting
                    if (liveView.CanChangeLiveSorting)
                    {
                        liveView.IsLiveSorting = IsLiveSortingRequested;
                        properties = liveView.LiveSortingProperties;
                        properties.Clear();

                        if (IsLiveSortingRequested)
                        {
                            foreach (string s in LiveSortingProperties)
                            {
                                properties.Add(s);
                            }
                        }
                    }

                    CanChangeLiveSorting = liveView.CanChangeLiveSorting;
                    IsLiveSorting = liveView.IsLiveSorting;

                    // filtering
                    if (liveView.CanChangeLiveFiltering)
                    {
                        liveView.IsLiveFiltering = IsLiveFilteringRequested;
                        properties = liveView.LiveFilteringProperties;
                        properties.Clear();

                        if (IsLiveFilteringRequested)
                        {
                            foreach (string s in LiveFilteringProperties)
                            {
                                properties.Add(s);
                            }
                        }
                    }

//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:CollectionViewSource.cs

示例4: ApplyPropertiesToView

 private void ApplyPropertiesToView(ICollectionView view)
 {
     int num;
     int count;
     Predicate<object> filterWrapper;
     if (view == null || this.deferLevel > 0)
     {
         return;
     }
     using (IDisposable disposable = view.DeferRefresh())
     {
         if (this.Culture != null)
         {
             view.Culture = this.Culture;
         }
         if (view.CanSort)
         {
             view.SortDescriptions.Clear();
             num = 0;
             count = this.SortDescriptions.Count;
             while (num < count)
             {
                 view.SortDescriptions.Add(this.SortDescriptions[num]);
                 num++;
             }
         }
         else if (this.SortDescriptions.Count > 0)
         {
             throw new InvalidOperationException("CollectionViewSource CannotShape Sorting");
         }
         if (this.filterHandlers == null)
         {
             filterWrapper = null;
         }
         else
         {
             filterWrapper = this.FilterWrapper;
         }
         if (view.CanFilter)
         {
             view.Filter = filterWrapper;
         }
         else if (filterWrapper != null)
         {
             throw new InvalidOperationException("CollectionViewSource CannotShape Filtering");
         }
         if (view.CanGroup)
         {
             view.GroupDescriptions.Clear();
             num = 0;
             count = this.GroupDescriptions.Count;
             while (num < count)
             {
                 view.GroupDescriptions.Add(this.GroupDescriptions[num]);
                 num++;
             }
         }
         else if (this.GroupDescriptions.Count > 0)
         {
             throw new InvalidOperationException("CollectionViewSource CannotShape Grouping");
         }
     }
 }
开发者ID:evnik,项目名称:UIFramework,代码行数:63,代码来源:CollectionViewSource.cs

示例5: ApplyPropertiesToView

        // Forward properties from the CollectionViewSource to the CollectionView
        void ApplyPropertiesToView(ICollectionView view) 
        {
            if (view == null || _deferLevel > 0) 
                return; 

            using (view.DeferRefresh()) 
            {
                int i, n;

                // Culture 
                if (Culture != null)
                { 
                    view.Culture = Culture; 
                }
 
                // Sort
                if (view.CanSort)
                {
                    view.SortDescriptions.Clear(); 
                    for (i=0, n=SortDescriptions.Count;  i < n;  ++i)
                    { 
                        view.SortDescriptions.Add(SortDescriptions[i]); 
                    }
                } 
                else if (SortDescriptions.Count > 0)
                    throw new InvalidOperationException(SR.Get(SRID.CannotSortView, view));

                // Filter 
                Predicate<object> filter;
                if (FilterHandlersField.GetValue(this) != null) 
                { 
                    filter = FilterWrapper;
                } 
                else
                {
                    filter = null;
                } 

                if (view.CanFilter) 
                { 
                    view.Filter = filter;
                } 
                else if (filter != null)
                    throw new InvalidOperationException(SR.Get(SRID.CannotFilterView, view));

                // GroupBy 
                if (view.CanGroup)
                { 
                    view.GroupDescriptions.Clear(); 
                    for (i=0, n=GroupDescriptions.Count;  i < n;  ++i)
                    { 
                        view.GroupDescriptions.Add(GroupDescriptions[i]);
                    }
                }
                else if (GroupDescriptions.Count > 0) 
                    throw new InvalidOperationException(SR.Get(SRID.CannotGroupView, view));
            } 
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:59,代码来源:CollectionViewSource.cs


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