Click here to Skip to main content
15,881,649 members
Articles / Desktop Programming / WPF

Multi-filtered WPF DataGrid with MVVM

Rate me:
Please Sign up or sign in to vote.
4.88/5 (16 votes)
18 Aug 2012CPOL4 min read 125.5K   9.5K   44  
A simple example of using multi-filters with a WPF DataGrid with MVVM.
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<!-- This is the style used to display enabled or disabled button images for removing filters-->
	<Style x:Key="ImageStyleForButtons" TargetType="{x:Type Image}">
		<Style.Triggers>
			<DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Value="True">
				<Setter Property="Source"  Value="/MultiFilteredDataGridMVVM;component/Resources/1385_Disable_16x16_72.png"/>                            
			</DataTrigger>
			<DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource AncestorType={x:Type Button}, Mode=FindAncestor}}" Value="False">
				<Setter Property="Source" Value="/MultiFilteredDataGridMVVM;component/Resources/1385_Disable_16x16_72_disabled.png"/>                            
			</DataTrigger>                        
		</Style.Triggers>
	</Style>
</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Neck deep in Social Network Analysis

Comments and Discussions