Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何明确地调用ItemsCollection.Filter?_.net_Wpf_Filter_Itemscollection - Fatal编程技术网

.net 如何明确地调用ItemsCollection.Filter?

.net 如何明确地调用ItemsCollection.Filter?,.net,wpf,filter,itemscollection,.net,Wpf,Filter,Itemscollection,我该怎么称呼像“DoFilter”这样的词 我将它的Filter属性设置为谓词。我在谓词中放置了一个断点,它只有在初始化ItemsCollection时才会到达那里,当我调用m_ItemsCollection.Refresh()时它不会到达那里。有几种情况下.Refresh()不起作用,但它确实起作用: collection.Filter = collection.Filter; 几个月前我遇到了这个。显然,在某些情况下,有一个bug阻止ItemsControl可靠地传递Refresh()调用

我该怎么称呼像“DoFilter”这样的词


我将它的Filter属性设置为谓词。我在谓词中放置了一个断点,它只有在初始化ItemsCollection时才会到达那里,当我调用m_ItemsCollection.Refresh()时它不会到达那里。

有几种情况下.Refresh()不起作用,但它确实起作用:

collection.Filter = collection.Filter;

几个月前我遇到了这个。显然,在某些情况下,有一个bug阻止ItemsControl可靠地传递Refresh()调用。我尚未调查详细信息。

刷新有时不起作用的原因是ItemsCollection上使用了以下代码:

   /// <summary>
    /// Set/get a filter callback to filter out items in collection.
    /// This property will always accept a filter, but the collection view for the
    /// underlying ItemsSource may not actually support filtering.
    /// Please check <seealso cref="CanFilter"/>
    /// </summary>
    /// <exception cref="NotSupportedException">
    /// Collections assigned to ItemsSource may not support filtering and could throw a NotSupportedException.
    /// Use <seealso cref="CanFilter"/> property to test if filtering is supported before assigning
    /// a non-null Filter value.
    /// </exception>
    public override Predicate<object> Filter
    {
        get
        {
            return (EnsureCollectionView()) ? _collectionView.Filter : MyFilter;
        }
        set
        {
            MyFilter = value;
            if (_collectionView != null)
                _collectionView.Filter = value;
        }
    } 
很抱歉回答这个老问题,但我觉得值得澄清一下

/// <summary>
    /// Re-create the view, using any <seealso cref="SortDescriptions"/> and/or <seealso cref="Filter"/>.
    /// </summary>
    public virtual void Refresh()
    {
        IEditableCollectionView ecv = this as IEditableCollectionView;
        if (ecv != null && (ecv.IsAddingNew || ecv.IsEditingItem))
            throw new InvalidOperationException(SR.Get(SRID.MemberNotAllowedDuringAddOrEdit, "Refresh"));

        RefreshInternal();
    }