I have a TextBox
in a WPF window bound to a dependency property of the window of type double
(see below). Whenever the user types in the TextBox
This is caused by it trying to apply the formatting after every character press.
As an alternative, I usually just style the TextBox
so it only applies formatting when it's not being edited
<Style TargetType="{x:Type TextBox}">
<Setter Property="Text" Value="{Binding SomeValue, StringFormat=C}" />
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="Text" Value="{Binding SomeValue, UpdateSourceTrigger=PropertyChanged}" />
</Trigger>
</Style.Triggers>
</Style>