I implemented an application, i use a combobox, and this combobox is filled with items out of a xml file. This works fine. Binding is:
<ComboBox ItemsSource="{Binding Source={StaticResource Vakken}}" DisplayMemberPath="@Name" Height="23" HorizontalAlignment="Left" Margin="215,67,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" SelectionChanged="comboBox1_SelectionChanged" />
But i also have a button, which allows the user to add an item to the xml file. It works perfectly to add a item to the xml file( so the writing method works) but the changes are not committed in the combobox. So is there anyway to refresh this combobox or something like that. Because the item which i just added, doesn’t stand in the combobox?
XML manipulation is something i would try to avoid, it’s a very nice format for small data-transfer and nice to parse from and serialize to and all that but it’s not native to the programming language and framework at hand.
I would parse the XML to an
ObservableCollection<T>once, if you bind to that your ComboBox will be updated (and you could in turn even update the XML if you must by subscribing to theCollectionChangedevent and serializing the collection back to XML).