ComponentOne DataFilter for WPF
DataFilters / XML Serialization/Deserialization
In This Topic
    XML Serialization/Deserialization
    In This Topic

    The DataFilter control supports serialization through SaveFilterExpression and LoadFilterExpression methods of the C1DataFilter class. The SaveFilterExpression method saves the current filter expressions from C1.Win.DataFilter.C1DataFilter.Filters collection to an XML file. The LoadFilterExpression method loads the saved filter expressions from an XML file.

    The following GIF demonstrates serialization and de-serialization support in the DataFilter control.

    The application shows serialization and deserialization in the Data filter.

    The following code shows an example of saving filter expressions to an XML file:

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        'Loads the current filter expressions from an xml file
        c1DataFilter.LoadFilterExpression("SavedFilters.xml")
        MessageBox.Show("Loaded saved Filter state.")
    End Sub
    
    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        //Saves the current filter expressions to an xml file
        c1DataFilter.SaveFilterExpression("SavedFilters.xml");
        MessageBox.Show("Filter state saved.");
    }
    

    The following code shows an example of loading filter expressions from an XML file:

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        'Saves the current filter expressions to an xml file
        c1DataFilter.SaveFilterExpression("SavedFilters.xml")
        MessageBox.Show("Filter state saved.")
    End Sub
    
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        //Loads the current filter expressions from an xml file
        c1DataFilter.LoadFilterExpression("SavedFilters.xml");
        MessageBox.Show("Loaded saved Filter state.");
    }