Dear expert,
Can we prevent this control from firing SelectedColorChanged event when the mouse is hovering on a color? What I want is fire this event when a color is selected by a mouse click.
Thank you.
Frank
The event firing when hovering is the intended behavior. You could listen to the DropDownClosed event, but that would also fire when hte drop down closes and the Advanced editor is opened.
There isn't a way to override this behavior.
Why in all of the world of coding would that be the intended behavior? Mousing over a color does not select it, proven by the fact if you mouse over it and then not click a color, the selected color is not changed.
You need two different events to handle two different actions. A mouse over shouldn't and doesn't select anything, so it should not fire the selected color changed event.
Add a second event for on mouse over / hover...
Hello,
Since this is the designed behavior of the control if you want this to be changed, you can suggest a new product idea for it here:
http://ideas.infragistics.com/
I am dealing with this same situation. I want to refresh the screen when the user has actually picked a color from the basic or advanced menu. I don't want to refresh every time the user hovers over a color. Is there no way to know when the user has actually selected a color?
I've got a workaround for now. Something like this.
In XAML you'll have to redefine the style for the color picker to add a click event to the Advanced button, so that you know when it is clicked. I just copied and pasted the entire style and added the click event AdvancedEditorButton_Clicked like this:
In code behind:
//Class wide variables.
private Color? originalColor = null;
private bool advancedPickerOpened = false;
private void AdvancedEditorButton_Clicked(object sender, RoutedEventArgs e) { advancedPickerOpened = true; }
private void XamColorPicker_DropDownOpened(object sender, EventArgs e)
{ XamColorPicker colorPicker = (XamColorPicker)sender; originalColor = colorPicker.SelectedColor; }
void colorPicker_SelectedColorChanged(object sender, SelectedColorChangedEventArgs e)
{ XamColorPicker colorPicker = (XamColorPicker)sender; if (!colorPicker.IsDropDownOpen && originalColor != e.NewColor) { UpdateColor(colorPicker); } }
void colorPicker_DropDownClosed(object sender, EventArgs e)
{ XamColorPicker colorPicker = (XamColorPicker)sender; if (advancedPickerOpened) { advancedPickerOpened = false; return; } if (colorPicker.SelectedColor != originalColor) { UpdateColor(colorPicker); } }
public void UpdateColor(XamColorPicker colorPicker) {
//Do work
}