C# 当我触摸webview内容时,然后在应用程序崩溃后触摸外部某处
我对这个很陌生,而且这不是我的代码。我发现什么都想不出来,但我已经尽力了。因此,我有一个C# 当我触摸webview内容时,然后在应用程序崩溃后触摸外部某处,c#,windows-phone-8.1,C#,Windows Phone 8.1,我对这个很陌生,而且这不是我的代码。我发现什么都想不出来,但我已经尽力了。因此,我有一个Grid元素,它包含FlipView和另一个Grid(它包含4个selectorbutton)。在FlipView内部,我有3个webview和Frame。现在有一件事我不知道——当我以某种方式与webview交互(滚动一个实例)并点击任何按钮时,应用程序崩溃。它抛出System.ArgumentException:值不在预期范围内。触摸框架,然后再触摸按钮就可以了。下面是xaml代码和按钮命令。 Xaml:
Grid
元素,它包含FlipView
和另一个Grid
(它包含4个selectorbutton
)。在FlipView
内部,我有3个webview
和Frame
。现在有一件事我不知道——当我以某种方式与webview交互(滚动一个实例)并点击任何按钮时,应用程序崩溃。它抛出System.ArgumentException:值不在预期范围内
。触摸框架
,然后再触摸按钮就可以了。下面是xaml代码和按钮命令。
Xaml:
<FlipView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</FlipView.ItemsPanel>
<WebView x:Name="web1"
Source="{Binding Model.Widget1Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None" IsTapEnabled="False"/>
<WebView x:Name="web2"
Source="{Binding Model.Widget2Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None"/>
<WebView x:Name="web3"
Source="{Binding Model.Widget3Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None"/>
<Frame Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
ManipulationMode="All" ManipulationCompleted="FlipView_ManipulationCompleted" ManipulationStarted="FlipViewItem_ManipulationDelta"
VerticalAlignment="Stretch"
Background="White"
x:Name="contentFrame" DataContext="{Binding Model.UserLoginViewModel}"/>
</FlipView>
<Grid Grid.Row="1" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<controls:SelectorButton x:Name="B1" Grid.Row="0" Grid.Column="0" Source="../images/tab_01.png" ActiveSource="../images/tab_active_01.png" ButtonCommand="{Binding Model.SetWebView1Command}"/>
<controls:SelectorButton x:Name="B2" Grid.Row="0" Grid.Column="1" Source="../images/tab_02.png" ActiveSource="../images/tab_active_02.png" ButtonCommand="{Binding Model.SetWebView2Command}"/>
<controls:SelectorButton x:Name="B3" Grid.Row="0" Grid.Column="2" Source="../images/tab_03.png" ActiveSource="../images/tab_active_03.png" ButtonCommand="{Binding Model.SetWebView3Command}"/>
<controls:SelectorButton x:Name="B4" Grid.Row="0" Grid.Column="3" Source="../images/tab_04.png" ActiveSource="../images/tab_active_04.png" ButtonCommand="{Binding Model.LoginCommand}" />
</Grid>
</Grid>
正如我之前提到的,代码是由其他人编写的,我不知道为什么会有这样或那样的事情。任何建议都将不胜感激。我能够管理应用程序,使其不会崩溃。例如,导致问题的行是
FlipView.SelectedIndex=1代码>我所做的是将此语句放入try
-catch
块中。它不再崩溃,有趣的是,它执行这一行,这样应用程序就可以正常工作。您需要获得有关生成异常的代码的更多信息(方法和行号)。没有它我们就无能为力。在选择了第二个按钮之后,我得到了很多信息:在Windows.UI.Xaml.Controls.Primitives.Selector.put_SelectedIndex(Int32值)在[…]Pages.MainPage.d_12.MoveNext()
有什么建议如何获取更多信息吗?我忘了提一件事-当我触摸webview,然后长按按钮时,它会正常工作。
<FlipView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</FlipView.ItemsPanel>
<WebView x:Name="web1"
Source="{Binding Model.Widget1Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None" IsTapEnabled="False"/>
<WebView x:Name="web2"
Source="{Binding Model.Widget2Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None"/>
<WebView x:Name="web3"
Source="{Binding Model.Widget3Url}"
Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Visibility="Visible" ManipulationMode="None"/>
<Frame Height="Auto"
Width="Auto"
HorizontalAlignment="Stretch"
ManipulationMode="All" ManipulationCompleted="FlipView_ManipulationCompleted" ManipulationStarted="FlipViewItem_ManipulationDelta"
VerticalAlignment="Stretch"
Background="White"
x:Name="contentFrame" DataContext="{Binding Model.UserLoginViewModel}"/>
</FlipView>
<Grid Grid.Row="1" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<controls:SelectorButton x:Name="B1" Grid.Row="0" Grid.Column="0" Source="../images/tab_01.png" ActiveSource="../images/tab_active_01.png" ButtonCommand="{Binding Model.SetWebView1Command}"/>
<controls:SelectorButton x:Name="B2" Grid.Row="0" Grid.Column="1" Source="../images/tab_02.png" ActiveSource="../images/tab_active_02.png" ButtonCommand="{Binding Model.SetWebView2Command}"/>
<controls:SelectorButton x:Name="B3" Grid.Row="0" Grid.Column="2" Source="../images/tab_03.png" ActiveSource="../images/tab_active_03.png" ButtonCommand="{Binding Model.SetWebView3Command}"/>
<controls:SelectorButton x:Name="B4" Grid.Row="0" Grid.Column="3" Source="../images/tab_04.png" ActiveSource="../images/tab_active_04.png" ButtonCommand="{Binding Model.LoginCommand}" />
</Grid>
</Grid>