I have TabControlwhere each TabItemhas a separate control as an element Content. Now I can easily complete the storyboard when switching to a tab using UserControl.LoadedEventTrigger. However, I also want to start the exit animation when switching from one tab to another (i.e., allow the old content control to be animated, and then the new content control entry animation).
Can this be done with standard WPF constructs?
If not, how do I get started developing a custom solution that handles this?
Edit:
I went ahead and made a modified TabControl that extends the TabControl base and overrides its method OnSelectionChangedas follows:
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
if (e.AddedItems.Count == 1 && e.RemovedItems.Count == 1)
{
var oldTab = e.RemovedItems[0] as TabItem;
if (oldTab != null)
{
var exitStoryboard =
if (exitStoryboard != null)
{
exitStoryboard.Completed = (_, __) => base.OnSelectionChanged(e);
exitStoryboard.Begin();
return;
}
}
}
base.OnSelectionChanged(e);
}
, , , base.OnSelectionChanged , -, , . ?