Используйте SelectionChanging
и SelectionChanged
, и вы можете применить это к нескольким tabcontrols. Я использую Devexpress, но он должен работать с любым элементом управления вкладками WPF 4.0, поскольку я использую только события SelectionChanging
и SelectionChanged
.
VB:
Private Sub TabControl_SelectionChanging(sender As Object, e As DevExpress.Xpf.Core.TabControlSelectionChangingEventArgs) Handles tcMaterials.SelectionChanging, tcSymbols.SelectionChanging, myTabControl1.SelectionChanging
Try
If Not e.OldSelectedItem Is Nothing Then
Dim Duration = New TimeSpan(0, 0, 0, 0, 500)
Dim FromOpac As New DoubleAnimation(1, 0, Duration)
Storyboard.SetTarget(FromOpac, CType(CType(e.OldSelectedItem, DXTabItem).Content, Grid))
Storyboard.SetTargetProperty(FromOpac, New PropertyPath((CType(CType(e.OldSelectedItem, DXTabItem).Content, Grid).OpacityProperty)))
Dim s As New Storyboard()
s.AccelerationRatio = 0.2
s.DecelerationRatio = 0.8
s.Children.Add(FromOpac)
s.Begin()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TabControl_SelectionChanged(sender As Object, e As DevExpress.Xpf.Core.TabControlSelectionChangedEventArgs) Handles tcMaterials.SelectionChanged, tcSymbols.SelectionChanged, myTabControl1.SelectionChanged
Try
If Not e.OldSelectedItem Is Nothing Then
Dim Duration = New TimeSpan(0, 0, 0, 0, 500)
Dim ToOpac As New DoubleAnimation(0, 1, Duration)
Storyboard.SetTarget(ToOpac, CType(CType(e.NewSelectedItem, DXTabItem).Content, Grid))
Storyboard.SetTargetProperty(ToOpac, New PropertyPath((CType(CType(e.NewSelectedItem, DXTabItem).Content, Grid).OpacityProperty)))
Dim s As New Storyboard()
s.AccelerationRatio = 0.2
s.DecelerationRatio = 0.8
s.Children.Add(ToOpac)
s.Begin()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub