Search code examples
windows-phone-7windows-phone-7.1windows-phone-8windows-phonewindows-phone-7.1.1

ArgumentException thrown in system OnTouch event


I have a simple application with two pages on it. The first page acts normally, and I have a button on the page that navigates to the second page.

However, when I get to the second page, any time I try to touch anything, the OnTouch event fires and an ArgumentException is thrown in the ListDictionaryInternal

However, I have nothing on the page that interacts with this OnTouch event, so I'm not sure what could be causing it.

The code to navigate to the new page:

string page = "valid";
NavigationService.Navigate(
    new Uri("/Dialog.xaml?page=" + page,
    UriKind.Relative)
);

The XAML of the page that crashes is very simple:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Name="AppName" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock Name="PageName" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Button Click="CancelDownload_Click" Opacity="1.0" Content="Cancel REST Request!" Background="Blue" Foreground="White" BorderBrush="Black" FontWeight="Bold" BorderThickness="1" x:Name="CancelData" VerticalAlignment="Center" Margin="90,327,90,291" Height="150" Width="300" Visibility="Collapsed" />
    </Grid>
</Grid>

What could be causing the OnTouch to fail in such a way?

Thank you for any help.


Solution

  • As it turns out, thee was a hack from the main page I had used to disable the scrolling of PivotItems when interacting with a nested Panorama.

    The code that caused the error:

    Touch.FrameReported += (s, e) =>
    {
        if (e.GetPrimaryTouchPoint(MainItems).Action == TouchAction.Up)
        {
            MainItems.IsHitTestVisible = true;
        }
    };