Is there any way to have a listbox populated by both static and dynamic items?
I am writing a windows phone 7 app and would like to have one static listboxItem at the top or bottom and then bind other items from the viewModel. I tried setting both a static listboxItem and then also a dataTemplate but the static item is replaced by the dynamic items.
Edit:
I have found several posts that show how to create a custom control that inherits from listbox which allows multiple templates. How might I create a custom control which adds a section for static items which are always present regardless of binding.
If you are trying to do MVVM and are also two-way binding the SelectedItem of the ListBox, it is going to be much easier/cleaner to just bind one collection to the ItemsSource property.
Can you just pre-populate the collection in your ViewModel with the static item? You could then merge your dynamic items into the already existing collection when they are available (coming back from a web service or whatever). It seems like you would want this kind of logic in your ViewModel anyway, and just expose a single list to the View to use with the ListBox.