private System.Windows.Controls.TextBox CreateTextBox(string propertyName) { var textBox = new System.Windows.Controls.TextBox { DataContext = _vm }; textBox.SetCulture(new CultureInfo("sv-SE")); var binding = new Binding { Path = new PropertyPath(propertyName), Source = _vm, Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(textBox, Input.ValueProperty, binding); textBox.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); return(textBox); }