Filters are used to decorate Actions and Commands. They can alter input and output parameters as well as handle exceptions or prevent the execution of the Action/Commands that they decorate. There are several filters provided out of the box, but you can also implement your own.
There are several custom filters available out of the box:
| Filter || Function |
| PreviewAttribute || Implements a pre-condition for method execution. Set the AffectsTriggers to true to allow the condition to affect the UI state, false otherwise (true is the default). |
| RescueAttribute || Decorates a class or method and redirects unhandled exceptions to the specified method. |
| AsyncActionAttribute || Besides enabling asynchronous actions, it serves as a post-execute filter for custom UI-bound callbacks. |
You can also implement your own filters by inheriting from Attribute and implementing one or more of the following interfaces:
| Interface || Function |
| IRescue || Enables a filter to handle exceptions. |
| IPreProcessor || Allows a filter to intercept input parameters or cancel the execution of a method. |
| IPostProcessor || Allows a filter to intercept the return value of a method. This is always called on the UI thread. |
| IHandlerAware || Allows a filter to hook into various aspects of the decorated classes at runtime. Mainly, provides access to IRoutedMessageHandler and IMessageTrigger. |
In addition to these interfaces, you may also wish to implement IInitializable if your filter needs to execute custom initialization logic.Note:
You can see an example of a custom filter in use in the CustomFilters sample.