0

Okay so I'm using the below code to display the camera in my app and it works great! the problem is when i navigate away and come back to the app using the back stack the camera is not showing until i call the code manually.

how can i get it to show automatically ?

Thank Youuu in advance

Dim cam As New Microsoft.Devices.PhotoCamera()

Public Sub New()
    InitializeComponent()
    SupportedOrientations = SupportedPageOrientation.Portrait
End Sub

Private Sub opening() Handles Me.Loaded
    cam = New Microsoft.Devices.PhotoCamera()
    viewfinderBrush.RelativeTransform = New CompositeTransform() With {.CenterX = 0.5, .CenterY = 0.5, .Rotation = 90}
    viewfinderBrush.SetSource(cam)
End Sub


Private Sub Closing() Handles Me.Unloaded
    cam.Dispose()


End Sub
4

1 回答 1

0

修复了我自己的问题,只是使用了受保护的覆盖潜艇:)

像这样

Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
    MyBase.OnNavigatedTo(e)
    cam = New Microsoft.Devices.PhotoCamera()
    viewfinderBrush.RelativeTransform = New CompositeTransform() With {.CenterX = 0.5, .CenterY = 0.5, .Rotation = 90}
    viewfinderBrush.SetSource(cam)
End Sub

Protected Overrides Sub OnNavigatedFrom(e As NavigationEventArgs)
    MyBase.OnNavigatedFrom(e)

    If cam IsNot Nothing Then
        cam.Dispose()
        cam = Nothing
    End If
End Sub
于 2013-08-11T14:11:45.617 回答