Hallo
beim Binden auf meine TextBox ist ein komischer Seiten-Effekt entstanden oder auch etwas komplet normales ... das weiß ich nicht:
Zur erklärung, wenn ich in eine TextBox gehe und einer Zahl von 5 - 9 eingebe und dann gedrückt halte, zählt die Textbox von alleine hoch.
Liegt das an meinem
Spoiler anzeigen
beim Binden auf meine TextBox ist ein komischer Seiten-Effekt entstanden oder auch etwas komplet normales ... das weiß ich nicht:
Zur erklärung, wenn ich in eine TextBox gehe und einer Zahl von 5 - 9 eingebe und dann gedrückt halte, zählt die Textbox von alleine hoch.
Liegt das an meinem
StringFormat
?C#-Quellcode
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void Bind<T>(T source, string propertyName, Control control, DependencyProperty dependencyProperty, IValueConverter valueConverter, string stringFormat = "")
- {
- Binding binding = new Binding()
- {
- Path = new PropertyPath(propertyName),
- Source = source,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- if (valueConverter != null) binding.Converter = valueConverter;
- if (!string.IsNullOrWhiteSpace(stringFormat)) binding.StringFormat = stringFormat;
- binding.NotifyOnSourceUpdated = true;
- control.SetBinding(dependencyProperty, binding);
- }
C#-Quellcode
- public class DoubleConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => value.ToString().EndsWith(".") ? $"{value}.0" : value;
- }[/spoiler][spoiler]