我在xaml项目中有一个主页面,我已经部署了代码来获取屏幕属性。当我旋转屏幕时,它会相应地更改页面的值。但是,当我将相同的代码放到从主页面(frame.navigate)启动的其他.xaml页面时,它会在visual studio中打开“app.givb”并突出显示“ Global.System.Diagnostics.Debugger.Break( )“代码中。当我旋转移动设备屏幕不旋转但是第二页打开并显示属性。请帮忙解决问题。非常感谢你。我的代码如下:
Private Sub ScreenAnalysis(sender As Object, e As SizeChangedEventArgs) Handles Me.SizeChanged, Me.Loaded
Dim PageWidth = Window.Current.Bounds.Width
Dim PageHeight = Window.Current.Bounds.Height
Dim ScreenWidth = DisplayInformation.GetForCurrentView.ScreenWidthInRawPixels()
Dim ScreenHeight = DisplayInformation.GetForCurrentView.ScreenHeightInRawPixels()
Dim ScreenScale = DisplayInformation.GetForCurrentView.ResolutionScale()
Dim ScreenOrientation = DisplayInformation.GetForCurrentView.CurrentOrientation()
screenproperties1.Text = "<--Page Properties-->" & vbCrLf & "Width: " & PageWidth & vbCrLf & "Height: " & PageHeight & vbCrLf & "<--Screen Properties-->" & vbCrLf & "Windth: " & ScreenWidth & vbCrLf & "Height: " & ScreenHeight & vbCrLf & "<--Other--> " & vbCrLf & "ScreenScale: " & ScreenScale & vbCrLf & "Screen Orientation: " & ScreenOrientation
End Sub
“app.g.i.vb”内容如下:
Option Strict Off
Option Explicit On
Namespace Global.Mechanical_Engineering_Tools
#If Not DISABLE_XAML_GENERATED_MAIN Then
Public Class Program
<MTAThread()> _
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks", " 10.0.17.0")> _
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Shared Sub Main(ByVal args() As String)
Global.Windows.UI.Xaml.Application.Start(Function(p) New Global.Mechanical_Engineering_Tools.App())
End Sub
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks", " 10.0.17.0")> _
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Sub Program
End Sub
End Class
#End If
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class App
Inherits Global.Windows.UI.Xaml.Application
Private _contentLoaded As Boolean
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks", " 10.0.17.0")> _
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public Sub InitializeComponent()
If _contentLoaded Then
Return
End If
_contentLoaded = true
#If Debug AndAlso Not DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT Then
AddHandler Me.DebugSettings.BindingFailed,
Sub(Sender As Global.System.Object, bindingFailedArgs As Global.Windows.UI.Xaml.BindingFailedEventArgs)
Global.System.Diagnostics.Debug.WriteLine(bindingFailedArgs.Message)
End Sub
#End If
#If Debug AndAlso Not DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION Then
AddHandler Me.UnhandledException,
Sub(sender As Global.System.Object, unhandledExceptionArgs As Global.Windows.UI.Xaml.UnhandledExceptionEventArgs)
If Global.System.Diagnostics.Debugger.IsAttached Then
Global.System.Diagnostics.Debugger.Break()
End If
End Sub
#End If
End Sub
End Class
End Namespace
答案 0 :(得分:0)
我不确定发生了什么,但是当我从[pagename] .g.i。[language]文件中收到错误时,通常是因为我的数据绑定存在问题。或许仔细检查那些?这是一个生成的文件,你收到错误,这意味着问题可能是两个文件(如.XAML和.VB)之间的连接,编译器无法捕获(如某些数据绑定问题)
答案 1 :(得分:0)
我发现了问题。问题在于事件类型已更改大小,加载的事件无法一起运行:
$csv = Get-Content .\input.txt # source CSV file
$cap = $csv[0] -split '\s+' # caption of CSV
# replace spaces separating columns, group objects by ID
($csv[1..$csv.Length] -replace '(\d+)\s+(.*)\s+(\d+)', '$1,$2,$3' |
ConvertFrom-Csv -Delimiter ',' -Header $cap | Group-Object ID).ForEach{
$_.Group | Export-Csv "$($_.Name).csv" # write result
}
因为 sizechanged 需要'SizeChangedEventArgs',但 Loaded 需要'RoutedEventArgs'