I finally resourt to implement a simple tabcontrol myself, because then I have control over everything.
<WrapPanel x:Name="WrapPanel_Main"> <!-- This is the TabControl -->
<Border x:Name="Border_Configuration" Margin="5,5,0,0" BorderThickness="4,4,4,0"> <!-- This is the first tab -->
<TextBlock x:Name="TextBlock_Configuration" Text="Configuration" Padding="5" MouseLeftButtonUp="TextBlock_Step_MouseLeftButtonUp"/>
</Border>
<Border Margin="5,5,0,0" BorderThickness="4,4,4,0"> <!-- This is the second tab -->
<TextBlock x:Name="TextBlock_Artists" Text="Artists" Padding="5" MouseLeftButtonUp="TextBlock_Step_MouseLeftButtonUp" />
</Border>
<Border Margin="5,5,0,0" BorderThickness="4,4,4,0"> <!-- This is the third tab -->
<TextBlock x:Name="TextBlock_ReleaseGroups" Text="Release Groups" Padding="5" MouseLeftButtonUp="TextBlock_Step_MouseLeftButtonUp"/>
</Border>
</WrapPanel>
<Border x:Name="Border_Placeholder" Grid.Row="1" Margin="5,0,5,5"> <!-- placeholder for the content of each tab -->
<ContentControl x:Name="ContentControl_Placeholder" Grid.Row="1" Padding="5" />
</Border>
And here the handler that takes care of the Mouse-Up-Event of the "Tabs". I created an interface, each usercontrol that is used as a content for the tab has to implement. This allows the user control to inform the "Tab Control" about unsaved changes and to take appropriate (user choice) action.
After that, it loads the new content and changes the appearance of the "Tab-Headers". The amount of more code this causes is in my opinion acceptable to the full control regarding tab changes.
private void TextBlock_Step_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
ICancelUnloading currentElement = ContentControl_Placeholder.Content as ICancelUnloading;
if (currentElement != null)
{
if (currentElement.UnsavedChanges)
{
MessageBoxResult result = MessageBox.Show("Yes: Save, No: Discard, Cancel: Stay", "Unsaved Changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
if (result == MessageBoxResult.Cancel)
return;
if (result == MessageBoxResult.Yes)
currentElement.Save();
}
}
TextBlock textBlock = sender as TextBlock;
if (textBlock != null)
{
switch (textBlock.Name)
{
case "TextBlock_Configuration":
ContentControl_Placeholder.Content = new ConfigurationView();
break;
case "TextBlock_Artists":
ContentControl_Placeholder.Content = new ArtistsView();
break;
case "TextBlock_ReleaseGroups":
ContentControl_Placeholder.Content = new ReleaseGroupsView();
break;
}
ActivateTab(textBlock);
}
}