FilterEventHandler 代理人

定義

Filter イベントを処理するメソッドを表します。

public delegate void FilterEventHandler(System::Object ^ sender, FilterEventArgs ^ e);
public delegate void FilterEventHandler(object sender, FilterEventArgs e);
type FilterEventHandler = delegate of obj * FilterEventArgs -> unit
Public Delegate Sub FilterEventHandler(sender As Object, e As FilterEventArgs)

パラメーター

sender
Object

イベントのソース。

e
FilterEventArgs

イベントのデータ。

次の例は、イベントのイベント ハンドラーを設定する方法を 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

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

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください