Xceed DataGrid for Silverlight Documentation
FilterRow Class
Members  Example 


Represents a row through which an end user can modify how the data in a grid is filtered.
Object Model
FilterRow ClassFilterExpressionBase Class
Syntax
'Declaration
 
<StyleTypedPropertyAttribute(Property="CellStyle", StyleTargetType=Xceed.Silverlight.DataGrid.FilterCell)>
Public Class FilterRow 
   Inherits Row
   Implements MS.Internal.IManagedPeer, MS.Internal.IManagedPeerBase, MS.Internal.INativeCoreTypeWrapper 
'Usage
 
Dim instance As FilterRow
[StyleTypedPropertyAttribute(Property="CellStyle", StyleTargetType=Xceed.Silverlight.DataGrid.FilterCell)]
public class FilterRow : Row, MS.Internal.IManagedPeer, MS.Internal.IManagedPeerBase, MS.Internal.INativeCoreTypeWrapper  
Remarks

By default, a filter row is not displayed; however, one can be added to the header or footer sections of a grid (see Headers and Footers topic).

Filter values entered in a filter cell will not be applied until an operator is selected. If one is already selected and the filter is changed, then the new filter will be applied automatically.

Values entered into the filter row are neither case sensitive nor time sensitive. If a case- or time- sensitive value is provided via a filter expression, an exception will be thrown. In other words, when creating a filter expression that is to be assigned to a filter row programmatically, its IsCaseSenstive and IsTimeSensitive properties must both be set to false.

Example
<sldg:DataGridControl x:Name="sldgDataGridControl"
                      ItemsSource="{Binding Path=Orders}">
    <sldg:DataGridControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <sldg:SignatureThemeResourceDictionary />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </sldg:DataGridControl.Resources>
    
    <sldg:DataGridControl.FixedHeaders>
        <CheckBox Content="Display only French-Speaking Countries"
                  Checked="CheckBox_Checked"
                  Unchecked="CheckBox_Unchecked"
                  Style="{StaticResource SignatureThemeCheckBoxStyle}"/>
        <sldg:FilterRow>
            <sldg:FilterRow.FilterExpression>
                <sldg:AndFilterExpression>
                    <sldg:FilterExpression MemberName="ShipVia"
                                           Value="3"
                                           FilterOperator="Equal" />
                    <sldg:FilterExpression MemberName="OrderDate"
                                           Value="2008/01/01"
                                           FilterOperator="GreaterThanOrEqual"
                                           IsTimeSensitive="False"/>                            
                </sldg:AndFilterExpression>
            </sldg:FilterRow.FilterExpression>
        </sldg:FilterRow>
    </sldg:DataGridControl.FixedHeaders>
</sldg:DataGridControl>
Private m_frenchCountries As New List( Of String)( New String( 27 )
       { "Belgium", "Benin", "Burkina-Faso", "Burundi", 
         "Cameroon", "Canada", "Central African Republic", "Chad", "Comoros", 
         "Congo", "Djibouti", "France", "Gabon", "Guinea", "Haiti", "Ivory Coast", 
         "Luxembourg", "Madagascar", "Mali", "Monaco", "Niger", "Rwanda", 
         "Senegal", "Seychelles", "Switzerland", "Togo", "Vanuatu" } ) 

Private Function CreateFilterExpression() As OrFilterExpression 
   Dim childExpressions As New List( Of FilterExpressionBase )()

   Dim country As String
   For Each country In m_frenchCountries 
      Dim expression As New FilterExpression( "ShipCountry", FilterOperator.Equal, country, False )
      childExpressions.Add( expression )
   Next country 

   Return New OrFilterExpression( childExpressions )
End Function 

Private m_filterExpression As OrFilterExpression = Nothing
Private Sub CheckBox_Checked( ByVal sender As Object, ByVal e As RoutedEventArgs )
   If m_filterExpression Is Nothing Then
      m_filterExpression = Me.CreateFilterExpression()
   End If 

   Me.sldgDataGridControl.FilterExpression = m_filterExpression
End Sub 

Private Sub CheckBox_Unchecked( ByVal sender As Object, ByVal e A RoutedEventArgs )
   Me.sldgDataGridControl.FilterExpression = Nothing
End Sub
private List<string> m_frenchCountries = new List<string>( new string[ 27 ] 
       { "Belgium", "Benin", "Burkina-Faso", "Burundi", 
         "Cameroon", "Canada", "Central African Republic", "Chad", "Comoros", 
         "Congo", "Djibouti", "France", "Gabon", "Guinea", "Haiti", "Ivory Coast", 
         "Luxembourg", "Madagascar", "Mali", "Monaco", "Niger", "Rwanda", 
         "Senegal", "Seychelles", "Switzerland", "Togo", "Vanuatu" } );

private OrFilterExpression CreateFilterExpression()
{
   List<FilterExpressionBase> childExpressions = new List<FilterExpressionBase>();

   foreach( string country in m_frenchCountries )
   {
      FilterExpression expression = new FilterExpression( "ShipCountry", FilterOperator.Equal, country, false );
      childExpressions.Add( expression );
   }

   return new OrFilterExpression( childExpressions );
}

private OrFilterExpression m_filterExpression = null;
private void CheckBox_Checked( object sender, RoutedEventArgs e )
{
   if( m_filterExpression == null )
      m_filterExpression = this.CreateFilterExpression();

   this.sldgDataGridControl.FilterExpression = m_filterExpression;
}

private void CheckBox_Unchecked( object sender, RoutedEventArgs e )
{
   this.sldgDataGridControl.FilterExpression = null;
}
Inheritance Hierarchy

System.Object
   System.Windows.DependencyObject
      System.Windows.UIElement
         System.Windows.FrameworkElement
            System.Windows.Controls.Control
               Xceed.Silverlight.DataGrid.ControlBase
                  Xceed.Silverlight.DataGrid.Row
                     Xceed.Silverlight.DataGrid.FilterRow

Requirements

Target Platforms: Windows 7, Windows Vista, Windows XP SP3, Windows Server 2008 family

See Also

Reference

FilterRow Members
Xceed.Silverlight.DataGrid Namespace
DataGridControl.FilterExpression Property

Manipulating Data

Filtering Data

Send Feedback