I have a FrameworkElementFactory works like a textbox created in the code, so there is no xaml code, and also I set this textbox with data binding in code. Now I want to update this textbox databinding by Enter key pressed. I have read one way for attached behavior in this Link, but it seems working with xaml code. Is there any way to set attached behavior in code behind?
ListBox DDF_List = new ListBox();
FrameworkElementFactory Editable_TextBox = new FrameworkElementFactory(typeof(TextBox));
Binding text_binding = new Binding("Value");
Editable_TextBox.SetBinding(TextBox.TextProperty, text_binding);
DataTemplate Text_Layout = new DataTemplate();
Text_Layout.VisualTree = Editable_TextBox;
DDF_List.ItemTemplate = Text_Layout;