I have many TabItems in my MainWindow.xaml.cs They are all with the same structures. This is one of them.
<TabItem Name="tabFeatured" Header="Featured" DataContext="{Binding TemplatesFeatured}">
<ScrollViewer>
<ItemsControl Name="ItemsControlFeatured" ItemsSource="{Binding}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button
Name="Featured"
Tag="{Binding Id}"
Click="Button_Download_Click">
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</TabItem>
and this is from c#
private void Button_Download_Click(object sender, RoutedEventArgs e)
{
Button b = (Button)sender;
string buttonTag = b.Tag.ToString();
string categoryName = b.Name.ToLower();
}
How can I take the TabItem's Name of the clicked button, so I can use its DataContext.
Every tabitem has different Context and I want to get it, depends on the button's Name.