The way the XAML event handler is installed explains that the TextBox1 control behavior: UpdateSourceTrigger=PropertyChanged sets the default behavior, which means that the source control ( TextBox1 ) is updated when the binding property changes. You can consider other TextBox events such as LostFocus and TextChanged , as shown below (C #):
TextBox1.LostFocus += (s, e) => TextBox_LostFocus(s, e); TextBox1.TextChanged += (s, e) => TextBox_TextChanged(s, e); private void TextBox_LostFocus(object sender, RoutedEventArgs e) { // Your event handling procedure, Formatting, etc. } private void TextBox_TextChanged(object sender, RoutedEventArgs e) { // Your event handling procedure, Formatting, etc. }
or using a simplified compact lambda-style syntax:
TextBox1.LostFocus += (s, e) => {//Your procedure, Formatting, etc}; TextBox1.TextChanged += (s, e) => {//Your procedure, Formatting, etc};
The same could be declared in XAML, but I recommend implementing functionality in the code module.
Regarding your second question, namely: CultureInfo implementation: you can save the CultureInfo declaration in XAML or implement it in the code module by placing it in any of the above event handlers, for example (re: Changing the default and decimal separator in the binding of Andrey Gordeev ):
String.Format(new CultureInfo("de-DE"), "{0:N}", valueTypeDouble);
Hope this helps.
Alex Bell Jun 04 '15 at 17:23 2015-06-04 17:23
source share