data binding - Accessing TextBoxes in WPF DataBound ListBox with foreach -
data binding - Accessing TextBoxes in WPF DataBound ListBox with foreach -
i have databound wpf listbox custom itemtemplate -> datatemplate. part of template listbox. on event i'd loop through textboxes in listbox , retreive values. possible?
you should able using itemcontainergenerator
, finding elements in template:
foreach (var item in lb.items) { var itemcontainer = lb.itemcontainergenerator.containerfromitem(item) listboxitem; // name textbox in template find here. var textbox = itemcontainer.contenttemplate.findname("?????", itemcontainer) textbox; var value = textbox.text; }
(if textboxes referred within listbox in template have dig deeper repeating same method.)
wpf data-binding
Comments
Post a Comment