ColorEditBox Validation

Editors for WPF Forum

Posted 8 years ago by Jake Pearson - Software Developer, Alion Science and Technology
Avatar
Hi,
Is there a way to set it so the ColorEditBox will set the value its bound to when the color drop down closes?

thanks,
Jake

Comments (4)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jake,

If you want to explicitly update the target of a binding when the ColorEditBox closes you'd need to:

1. Add a handler for the DropDownClosed event
2. Get the BindingExpression associated with the ColorEditBox.Value property
3. Call it's UpdateTarget method


Actipro Software Support

Posted 8 years ago by Jake Pearson - Software Developer, Alion Science and Technology
Avatar
Hi,
I overrode ColorEditBox with this code, but it didn't help. Any idea?
    public class ColorView : ColorEditBox
    {
        protected override void OnDropDownClosed(System.Windows.RoutedEventArgs e)
        {
            base.OnDropDownClosed(e);

            BindingOperations.GetBindingExpressionBase(this, ColorEditBox.ValueProperty).UpdateTarget();
        }
    }
Thanks,
Jake
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jake,

Sorry, I'm not sure why it's not working. The ColorEditBox.Value should be updated by that time. If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 8 years ago by Jake Pearson - Software Developer, Alion Science and Technology
Avatar
Hi,
I found a solution on Stackoverflow. I added a modifier to the binding expression so it looks like this:
<v:ColorView Value="{Binding Colors.BinSome, UpdateSourceTrigger=PropertyChanged}" />
The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.