views:

347

answers:

0

I found and inserted the code below on my navigation-based WPF application~ It worked on my (development) machine no problem but when I released it on the workstations, it was quite slow. I noticed that when the application is not maximized, it works at normal speed, but when the app is maximized, it looked like the application stops for a whole second with a page on top of another..

XAML

<Grid>
    <Image Stretch="UniformToFill" Source="/Keion-Wall.jpg"/>
    <Frame Name="Nodoka" NavigationUIVisibility="Hidden"/>
    <Canvas Name="TransitPlaceholder" IsHitTestVisible="False"/>
</Grid>

VB Code Behind

Private lastPageBrush As VisualBrush    

Private Sub Nodoka_Navigating(ByVal sender As Object, ByVal e As System.Windows.Navigation.NavigatingCancelEventArgs) Handles Nodoka.Navigating
Dim lastPage As Page = CType(Me.Nodoka.Content, Page)
If lastPage IsNot Nothing Then
        lastPageBrush = New VisualBrush(lastPage)
        lastPageBrush.Viewbox = New Rect(0, 0, lastPage.ActualWidth, lastPage.ActualHeight)
        lastPageBrush.ViewboxUnits = BrushMappingMode.Absolute
        lastPageBrush.Stretch = Stretch.None
End If
End Sub

Private Sub Nodoka_Navigated(ByVal sender As Object, ByVal e As System.Windows.Navigation.NavigationEventArgs) Handles Nodoka.Navigated
If lastPageBrush IsNot Nothing Then
        TransitPlaceholder.Background = lastPageBrush
        lastPageBrush = Nothing
        Dim sb As Animation.Storyboard = Me.FindResource("Transit")
        sb.Begin(Me.Nodoka)
End If
End Sub

Am I doing somehting wrong? Is there a better way to implement the "Fade" transition on WPF?