How to clear the data from a DataGrid using WPF in C#

I implemented some filtering into one of my DataGrids which required that a reset the initial result set. With a single line of code you can empty out the contents of the DataGrid.

datagridResults.ItemsSource = null;

Once I reset the contents to empty, I could then add the filtered content back into the DataGrid using the ListCollectionView.Filter method.

NOTE: I populated a DataTable with the results of the filter method. Each time I did a filter I needed to clear the filtered results in the DataTable, but did not want to reset the DataTable column structure. I achieved this by using the Clear method of the DataTable.

MyDataTable.Clear();