I have a WPF application containing many TextBox es having different types of bindings, all of which have the same StringFormat property (its technical application, text fields should display values ββwith units of "xxx mm" ...)
I want to configure binding in XAML / Designer, but I would like to avoid setting the TextFormat property on each individual Binding. Is there any way to do this with styles?
If I try to set the binding in Setter for the Text property, for example
<Style x:Name="mmtext" TargetType="TextBox" x:Key="mmtext"> <Setter Property="Text" Value="{Binding Path=A,StringFormat={}{0} mm}" /> </Style>
I need to provide Path in the Setters Value property, and I cannot determine the binding in the XAML itself (since this will override the value given in the style).
Is there a way to set / change only the StringFormat property in one binding (i.e. the Binding property for the Text property) using style?
Or do I need to look for templates or a custom control?
source share