Adding TabItems dynamically
I have a TabControl control <TabControl Name="Farms_myVillages" ItemsSource="{Binding Villages}"> </TabControl/> In the code behind I add some tabs dynamically to the TabControl as follows: foreach (Village vill in Villages) { TabItem tab = new TabItem(); tab.Header = vill.Name; VillageUserControl c = new VillageUserControl(); c.DataContext = vill; tab.Content = c; Farms_myVillages.Items.Add(tab); } where VillageUserControl is a UserControl that deal with the specified village. This code works fine and it gets the expected results... The problem is that I don't want this to be in the code