I have combobox data binding to available system colors. When the user selects a color, the following code is run:
private void cboFontColour_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Color colour = (Color)(cboFontColour.SelectedItem);
}
This throws a cast exception with the following message: "The specified cast is invalid." When I hover over cboFontColour.SelectedItem in the debugger, it is always a Color object.
I do not understand why the system, it would seem, cannot distinguish it from Color to Color, any help will be very necessary.
source
share