To do exactly what your question asks, you could try using a converter on the SelectedQuarksList binding that does a ".Select(q => q.Value)" in the ConvertBack function.
To get the behavior you want, I have done this successfully in the past (example with 2 of your values), this sets up the enum as "Flags" so the value sequence goes 0, 1, 2, 4...:
<StackPanel Orientation="Horizontal">
<Checkbox Content="Up" IsChecked="{Binding Path=SelectedQuarksFlags, Converter={Static Resource HasFlagToBoolConverter}, ConverterParamater={x:Static Quarks.Up}}"
<Checkbox Content="Magical Being" IsChecked="{Binding Path=SelectedQuarksFlags, Converter={Static Resource HasFlagToBoolConverter}, ConverterParamater={x:Static Quarks.Charm}}"
</StackPanel>
The converter looks like:
Quark _lastSeenValue;
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Quark paramQuark = (Quark)parameter;
Quark currentQuark = (Quark)value;
_lastSeenValue = currentQuark;
return currentQuark.HasFlag(paramQuark);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Quark newQuark = _lastSeenValue;
Quark paramQuark = (Quark)parameter;
if ((bool)value)
{
newQuark |= paramQuark;
}
else
{
newQuark &= ~paramQuark;
}
_lastSeenValue = newQuark;
return newQuark;
}
This could be converted to add or remove from a list relatively easily, but I know the code above works.