好的,所以我使用下面的代码在我的应用程序中显示相机,效果很好!问题是当我离开并使用后台回到应用程序时,相机不会显示,直到我手动调用代码。
如何让它自动显示?
提前感谢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
答案 0 :(得分: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