WPF-AutoComplete-TextBox: Binding to the text property with UpdateSourceTrigger=PropertyChanged doesn't work

So one solution would be to change the xaml to

<TextBox x:Name="PART_Editor"
                                             HorizontalAlignment="Stretch"
                                             VerticalAlignment="Center"
                                             Style="{StaticResource ResourceKey=TransparentTextBoxStyle}"
                                             Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

This would have a very minor performance hit, however clearly no one is relying on this property currently. I would like if it could somehow automatically use the right one or be a user preference. I think we could do the user preference by adding another parameter on the AutoCompleteTextBox of “UpdateTextExplicitly” and then manually establish the binding in code behind rather than in xaml.

I figured open an issue for discussion.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Go on with option 2, so user can choice what is better… Agree?

On Nov 26, 2017 19:23, “Mitch Capper” notifications@github.com wrote:

I wish:) As far as I know we cannot have the binding mirror the parent. Some googling has others with custom user controls having the same issue. I see we have 3 options:

  1. Change the xaml we have to always do propertychanged, a minor performance hit occurs all we are doing is updated the backend value however so performance hit should be extremely negligible ( https://stackoverflow.com/questions/6532383/textbox- updatesourcetrigger-propertychanged-does-it- really-affect-performanc?rq=1 https://stackoverflow.com/questions/6532383/textbox-updatesourcetrigger-propertychanged-does-it-really-affect-performanc?rq=1 ). As long as the user doesn’t change their code to also update on PropertyChanged their code will not have the binding called any more often.
  2. We add another property to the control like UpdateTextOnPropertyChanged and then bind the xaml to the class in code behind, this way the user has full control on if we are binding in
  3. We do nothing, people already use the control without issue and I can use some View hacking to get around the problem for myself.

Personally I think performance wise it would be fairly minor to do item 1 but let me know the preferred call and I can do a PR.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/quicoli/WPF-AutoComplete-TextBox/issues/9#issuecomment-347031670, or mute the thread https://github.com/notifications/unsubscribe-auth/AH_-j7UQv4RlEvpnW2RKAQ4v0zFlpvL4ks5s6bqkgaJpZM4QqLtx .