I am creating a little stock-management tool for private use.
I have different views, which need similar but different filters. As an example I have a "current stock" list where I can filter for supplier, product group and name. I have the same list again but with additional filters for certain boolean flags. I am going to create a little statistic view where I will need all of the mentioned filters and some more like date range.
An last but not least I am creating a little csv Export where I have similar requirements as in the statistic view.
It isn't much but enough to think about a decent architecture. If you do it right on a small scale, chances are you do it right on bigger projects.
I use WPF with MVVM.
So far I have thought of some ways to tackle my problem:
Individual filter for each view: It is of course the most flexible variant but also leads to the most work if something concerning the filters is changed.
Filter generator: A control gets generated according to the configuration, sounds good but i loss the flexibility of styling the filter according to the view (i could add this to the configuration, but it would still lose me the advantages of xaml) and I can't really preview it in xaml during design time.
Creating a single ViewModel which contains all possible filters and Controls + ViewModels for each filter type (Checkbox, Combobox, Textbox). This approach would allow my to simply style the filter in xaml by using the filter controls for each view while capsuling the filter VM in one implementation.
For me the 3. option looks preferable but as i have never done anything alike, so I am looking for some feedback on how such a problem is usually approached or if some related pattern exist.