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 示しています。 この例の listingDataView は、CollectionViewSource のインスタンスです。

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

次の例は、フィルター イベント ハンドラーの例 ShowOnlyBargainsFilter の実装を示しています。 このイベント ハンドラーでは、 プロパティをFilterEventArgs.Accepted使用して、 が $25.00 以上のオブジェクトCurrentPriceを除外AuctionItemします。

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

完全な例については、「 データ バインディング のデモ」を参照してください。

適用対象

こちらもご覧ください