For anyone looking to do this, I have figured out a (admittedly very hacky) way to do this. In your ControlTemplate for your AutoFilterControlStyle, place a hidden ListBox with the name "PART_DistinctValuesHost". Also place an instance of your custom AutoFilterControl, like so:
<ControlTemplate TargetType="{x:Type DataGrid:AutoFilterControl}">
<Border Background="White" BorderThickness="1">
<Border.BorderBrush>
<SolidColorBrush Color="Black" />
</Border.BorderBrush>
<Grid Background="White" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListBox Name="PART_DistinctValuesHost" Visibility="Hidden" SelectionMode="Extended" />
<CustomAutoFilterControls:MyCustomAutoFilterControl Grid.Row="0" Loaded="customAutofilter_Loaded"/>
</Grid>
</Border>
</ControlTemplate>
You custom Autofilter control must have a property of type ListBox (technically, it can be of type Selector, but as far as I know making it a ListBox type is the easiest way to enable multiple selected items). Hook into the custom autofilter control's Loaded event and assign the hidden ListBox to the custom autofilter's ListBox property (there's probably a way to do this with a binding, but I'm not good enough with bindings to get that working):
private
void customAutofilter_Loaded(object sender, RoutedEventArgs args)
{
MyCustomAutoFilterControl autoFilterControl = sender as MyCustomAutoFilterControl;
if (autoFilterControl != null)
{
ListBox selector =
(
ListBox)((FrameworkElement)(autoFilterControl.Parent)).FindName("PART_DistinctValuesHost");
//ItemsHost is the ListBox property
autoFilterControl.ItemsHost = selector;
}
}
In your custom autofilter control, whenever you need to access the list of distinct values, you can do it via ItemsHost.Items (or ItemsHost.SelectedItems to get the currently selected values). You can select distinct values by adding to ItemsHost.SelectedItems, clear selected values via ItemsHost.SelectedItems.Remove() or Clear(), etc.
As I said: an extremely ugly hack, but if you need to give your users a more complex set of options for autofiltering, this seems to be the only way to do so right now. This also gives you the opportunity to present the user with different filtering options depending on the column's data type. For instance, you can give the user a textbox and filter out distinct values visible to the user based on the text entered when the column has strings, and you can also give the user a pair of datepickers to choose a date range if the column has DateTime objects. All you need to do is set each column's AutoFilterControlStyle to a different style depending on data type.