0

I'm interested in creating a new FilterEventHandler and associating it to a CollectionViewSource. All works fine, unless I want this handler to receive a parameter (let's say "price") in order to help with the filtering process.

However, when I try to put this extra-parameter, I'm getting a message which tells me that no overload matches the FilterEventHandler delegate signature (that's true, btw :p).

How can I achieve what I want? Is it possible? Or ... should I need to use a global variable instead a parameter in order to store that value and use it from the filtering method?

4

1 回答 1

1

创建一个包含您需要的所有参数的新对象。例如

公共 FilterData { 小数价格 {get;set;} int Quantity{get;set;} }

将此对象设置为 FilterEventArgs Item 属性。

现在,当引发此事件时,请检查 Item 属性是否为 FilterData 类型。如果是这样,请投射到 FilterDate 和瞧!您现在可以访问数量、价格以及您想要添加的任何其他属性。

于 2012-12-06T12:06:46.997 回答