سؤال

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
هل كانت مفيدة؟

المحلول

Fixed my Own Problem, just used protected overide subs :)

Like So

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top