[英]Windows Phone App State & Camera
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 预先感谢Youuu
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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.