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

如需完整範例,請參閱 資料系結示範

適用於

另請參閱