Updating datasource from bound Ribbon textbox after edit

Ribbon for WPF Forum

Posted 16 years ago by Derek Smithson - Software Developer, Vista Systems, Corp.
I'm using the WPF ribbon control in my application (version 4.0.0457 of the WPF Suite), and I've noticed that a datasource bound to the Text property of the Textbgox may or may not be updated depending on the action a user takes to release focus of the TextBox control.
<ribbon:TextBox Width="100" Label="Name" Text="{Binding Path=Name}" />
The binding source is updated properly when:
  • Tabbing out of text control after making text changes
The binding source is not updated when:
  • Pressing enter after making text changes
  • Clicking another control with the mouse after making changes to text
I've been able to make this work by adding an event setter to a default style for the ribbon textbox that forces a data binding source update when keyboard focus is lost (shown below), but this seems like a long way to resolve something basic that I must be missing, so I figured I'd ask for help. If anyone has any ideas please let me know.

private void TextBox_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
    ActiproSoftware.Windows.Controls.Ribbon.Controls.TextBox ribbonBox = sender as ActiproSoftware.Windows.Controls.Ribbon.Controls.TextBox;
    if (ribbonBox != null)
        DependencyProperty textProp = ActiproSoftware.Windows.Controls.Ribbon.Controls.TextBox.TextProperty;
        BindingExpression binding = ribbonBox.GetBindingExpression(textProp);
        if (binding != null)

Comments (1)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Derek,

The ribbon:TextBox actually inherits the standard WPF TextBox directly and doesn't make any changes to the Text property. I would first ask you to see if this same issue occurs if you put a native WPF TextBox in its place with the same settings (other than Label of course).

My guess is that you will see the same behavior. If so, you may want to ask in the Microsoft WPF forums:

Perhaps you can use a different Binding.UpdateSourceTrigger setting? But for TextBoxes I believe Microsoft defaults it to LostFocus.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.