This project is read-only.

Binding to Fluent.ComboBox CurrentTextProperty does not work

Aug 3, 2010 at 5:21 PM
Edited Aug 3, 2010 at 5:22 PM

Hello List !

I tried to declare a binding targeting the CurrentTextProperty of the Fluent.ComboBox. The source of the binding is a public property of some of my objects.

It seems that binding does not work here for some reason. I see that the CurrentText property of the ComboBox has the value I enter/select, but the binding source is not updated. However, the same does work well with the ContentProperty of a Fluent.TextBox control.

There's one difference between the dependecy property declarations of the two controls:

1) For the ComboBox it is:

public static readonly DependencyProperty CurrentTextProperty =
  DependencyProperty.Register("CurrentText", typeof(string), typeof(ComboBox), new UIPropertyMetadata("",OnCurrentTextChanged));

2) For the TextBox it's:

        public static readonly DependencyProperty ContentProperty =
            DependencyProperty.Register("Content", typeof(string), typeof(TextBox), 
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, 
                null, null, true, UpdateSourceTrigger.LostFocus));

Maybe the reason for the not-working binding is the UIPropertyMetadata-style of declaration for the ComboBox.

Can anyone help / fix this?


Oct 6, 2010 at 5:20 PM

I had the same problem when I wrapped MyUserControl inside of Gallery.

It worked when I moved MyUserControl ouside of Gallery.

Admittedly, I haven't verified my therory (because, as it turns out, I didn't have to use Gallery) BUT, I think it's because Gallery sets it's own DataContext (thus resetting the DataContext for child controls as well).


Maybe this will give you a direction to go (for instance use Styles and TemplateBinding to get the DataContext outside of ComboBox)