I have added 1 tab to tab control in design time in wpf .Now I want to add extra tabs to tabcontrol using MVVM pattern
Below is my code and what i have tried.
<TabControl ItemsSource="{Binding ContainerTabItems, Mode=TwoWay}" SelectedIndex="{Binding WizardModel.TabIndexValue, Mode=TwoWay}" x:Name="tabControl1">
<TabControl.Items>
<TabItem Header="Page Configuration">
<Button Content="Search" x:Name="btnSearch" Command="{Binding SearchClick}" />
</Grid>
</TabItem>
</TabControl.Items>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TabItem Header="{Binding Header}">
<TabItem.Content>
<ContentControl Content="{Binding UcContainer}"></ContentControl>
</TabItem.Content>
</TabItem>
</DataTemplate>
</ItemsControl.ItemTemplate>
</TabControl>
When I click on btnSearch button I have to add new tab to tabcontrol using MVVM
void SearchClickCommand_Execute(object parameter)
{
ContainerTabItems.Add(new ContainerTab()
{
Header="Search",
UcContainer=new SearchGrid(newSearchContainer())
});
}