FilterEventArgs.Item 属性

定义

获取筛选器应测试的对象。

public:
 property System::Object ^ Item { System::Object ^ get(); };
public object Item { get; }
member this.Item : obj
Public ReadOnly Property Item As Object

属性值

筛选器应测试的对象。 默认值为 null

示例

以下示例演示如何为 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

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

适用于

另请参阅