Xceed Toolkit Plus for WPF v4.6 Documentation
FilterExpression Class
Members  Example 


Xceed.Wpf.ListBox Assembly > Xceed.Wpf.Data Namespace : FilterExpression Class
Represents a filter expression, which states that an item must match the specified criteria in order to be included.
Syntax
'Declaration
 
<DebuggerDisplayAttribute("FilterBy = {DebuggerDisplayString}")>
Public NotInheritable Class FilterExpression 
   Inherits FilterExpressionBase
'Usage
 
Dim instance As FilterExpression
[DebuggerDisplay("FilterBy = {DebuggerDisplayString}")]
public sealed class FilterExpression : FilterExpressionBase 
Remarks

Once the filter expression has been created, it is considered "frozen" and its values can no longer be modified.

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
   Xceed.Wpf.Data.FilterExpressionBase
      Xceed.Wpf.Data.FilterExpression

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FilterExpression Members
Xceed.Wpf.Data Namespace
cf224116-45e2-4539-9fd6-71cc219add2e