This itemtemplate has two "modes". One for edit (when it is turned on textboxes are visible) and another one for save (labels are visible). I have just coped with saving. I wrote function, which sets suitable controls. And also this function saves all date from an item to an object. (A collection of these objects is exporting to xml file).
//This is a begging of this sub
If ItemsListBox.ItemContainerGenerator.Status = System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated Then
For Each listBoxItem As Object In ItemsListBox.Items
If listBoxItem Is ItemsListBox.SelectedItem Then
Dim container As ListBoxItem = TryCast(ItemsListBox.ItemContainerGenerator.ContainerFromItem(listBoxItem), ListBoxItem)
Dim listBoxItemBorder As Border = TryCast(VisualTreeHelper.GetChild(container, 0), Border)
Dim presenter As ContentPresenter = TryCast(VisualTreeHelper.GetChild(listBoxItemBorder, 0), ContentPresenter)
Dim bd As Border = TryCast(container.ContentTemplate.FindName("BD", presenter), Border)
Now, I have problem with load. I cannot do it in the same way as "save". I have made up a (stupid ) solution. I added to itemtemplate's field a binding. (Item is load from an object). Despite, it is stupid, it also does not work! Because of combobox. I have a function Combobox_onLoad, which fills this control. The problem is, Combobox_onLoad is called after binding and I always have the same value, which is not always right.
Please advice me, what should I do. It is possible to do this listbox in this way? Maybe, I should create two itemtemplates for listbox?
Bookmarks