FilterEventArgs.Accepted 属性

定义

获取或设置一个值,该值指示项是否通过筛选器。

public:
 property bool Accepted { bool get(); void set(bool value); };
public bool Accepted { get; set; }
member this.Accepted : bool with get, set
Public Property Accepted As Boolean

属性值

如果项通过了筛选器,则为 true;否则为 false。 默认值为 true

示例

下面的示例演示如何为 CollectionViewSource.Filter 事件设置事件处理程序。 在此示例中,listingDataViewCollectionViewSource 的实例。

listingDataView.Filter += new FilterEventHandler(ShowOnlyBargainsFilter);
AddHandler listingDataView.Filter, AddressOf ShowOnlyBargainsFilter

以下示例演示示例 ShowOnlyBargainsFilter 筛选器事件处理程序的实现。 此事件处理程序使用 FilterEventArgs.Accepted 属性筛选出 AuctionItem 具有 CurrentPrice $25.00 或更高值的对象。

private void ShowOnlyBargainsFilter(object sender, FilterEventArgs e)
{
    AuctionItem product = e.Item as AuctionItem;
    if (product != null)
    {
        // Filter out products with price 25 or above
        if (product.CurrentPrice < 25)
        {
            e.Accepted = true;
        }
        else
        {
            e.Accepted = false;
        }
    }
}
Private Sub ShowOnlyBargainsFilter(ByVal sender As Object, ByVal e As FilterEventArgs)
    Dim product As AuctionItem = CType(e.Item, AuctionItem)
    If Not (product Is Nothing) Then
        'Filter out products with price 25 or above
        If product.CurrentPrice < 25 Then
            e.Accepted = True
        Else
            e.Accepted = False
        End If
    End If
End Sub

有关完整示例,请参阅 数据绑定演示

适用于

另请参阅