문제

'dofilter'와 같은 것을 어떻게 호출합니까? System.Windows.Controls.ItemCollection?

필터 속성을 술어로 설정했습니다. 술어에 중단 점을 놓았는데, Itemscollection이 초기화 될 때만 M_ITEMSCOLLECTION.REFRESH ()가 아니에요.

도움이 되었습니까?

해결책

.refresh ()가 작동하지 않는 몇 가지 상황이 있지만 다음과 같습니다.

collection.Filter = collection.Filter;

나는 몇 달 전에 이것을 달렸다. 분명히 특정 상황에서 Itemscontrol이 새로 고침 () 호출을 안정적으로 전달하는 것을 막는 버그가 있습니다. 세부 사항을 조사하지 않았습니다.

다른 팁

새로 고침이 작동하지 않는 이유는이 코드가 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;
        }
    } 

필터가 Itemscollection 자체가 아닌 기본 수집보기에서 설정되고 있습니다.

그런 다음 기본 새로 고침 메소드는 실제로 Do Anything을 호출하지 않습니다. _collectionView, 그래서 새로 고침은 아무것도하지 않습니다!

/// <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();
    }  

오래된 질문에 응답해서 죄송하지만 명확히 할 가치가 있다고 느꼈습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top