XamlParseException при загрузке страницы

Я обнаружил странную проблему в своем приложении. Когда я открываю одну из страниц, метод InitializeComponent() приложения создает исключение XamlParseException. Что я могу сделать, чтобы избавиться от этой проблемы? Я также не нашел очевидных ошибок в своем коде xaml. Здесь вы можете увидеть мои файлы .cs и .xaml страницы:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;

namespace app_name
{
public partial class newsummaryPage : PhoneApplicationPage
{
    List<String> savingList;
    List<String> projectList;
    List<String> subjectsList;

    IsolatedStorageSettings settings;
    Boolean amISelectingProjects = true;
    Boolean firstSelection = true;

    String practicesummaryText;
    public newsummaryPage()
    {
        InitializeComponent();

        //Initialize settings
        settings = IsolatedStorageSettings.ApplicationSettings;
    }

    private void nextButton_Click(object sender, RoutedEventArgs e)
    {
        //Load existing list into the savingList (For temporary storage)
        savingList = null;
        savingList = readSetting("practiceList") != null ? (List<String>)readSetting("practiceList") : new List<String>();

        //Remove existing practiceList from IsolatedStorage
        settings.Remove("practiceList");

        //Add the new practice summary to the savingList
        savingList.Add(practiceTextBox.Text.ToString());

        //Save the savingList into practiceList in IsolatedStorage
        settings.Add("practiceList", savingList);

        //Save the summary text itself. Add "-practicesummary" to the end of the name to be able to add it without conflicts with the projectList and it's references
        settings.Add(practiceTextBox.Text.ToString() + "-practicesummary", practicesummaryText);

        //Save the settings
        settings.Save();

        MessageBox.Show("next");
    }

    private void newsummaryPage_Loaded(object sender, RoutedEventArgs e)
    {
        //Initialize the list
        projectList = new List<String>();
        try
        {
            //Load existing list
            selectprojectsandsubjectsListBox.Items.Clear();
            projectList.Clear();
            MessageBox.Show("loaded");
            projectList = readSetting("projectList") != null ? (List<String>)readSetting("projectList") : new List<String>();

            selectprojectsandsubjectsListBox.ItemsSource = projectList;
        }
        catch (Exception)
        {
            //run method CurrentProjectNotEmpty();
        }
    }

    private static object readSetting(string key)
    {
        return IsolatedStorageSettings.ApplicationSettings.Contains(key) ? IsolatedStorageSettings.ApplicationSettings[key] : null;
    }

    private void selectprojectsandsubjectsListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
    {
    }

    private void selectprojectsandsubjectsListBox_Tap(object sender, System.Windows.SizeChangedEventArgs e)
    {
        //Select a project/subject depending on the amISelectingProjects variable
        if (amISelectingProjects.Equals(true))
        {
            //The user is selecting a project. Get the name from the project and use it to get the subjects
            var selectedItem = selectprojectsandsubjectsListBox.SelectedItem as String;
            String item = selectedItem;

            MessageBox.Show("select");
            subjectsList = readSetting(item) != null ? (List<String>)readSetting(item) : new List<String>();
            selectprojectsandsubjectsListBox = null;
            selectprojectsandsubjectsListBox.ItemsSource = subjectsList;

            //Set amISelectingProjects to false so that the user can select subjects next time
            amISelectingProjects = false;

            //Set the ListBox to multiple selection mode for selecting multiple subjects
            selectprojectsandsubjectsListBox.SelectionMode = SelectionMode.Multiple;

            //Tell the user what he should do next
            MessageBox.Show("The subjects corresponding the the project you selected will now appear in the list. Tap on all the items you want to create a summary of and then press create when you're finished.");
        }
        else if (amISelectingProjects.Equals(false))
        {
            //The user is selecting a subject. Select multipe
            if (firstSelection.Equals(true))
            {
                practicesummaryText = selectprojectsandsubjectsListBox.SelectedItem as String;
                firstSelection = false;
            }
            else if (firstSelection.Equals(false))
            {
                //This is not the first subject that the user selects, therefore add some characters in between
                practicesummaryText = practicesummaryText + ". New subject= " + selectprojectsandsubjectsListBox.SelectedItem as String;
            }
        }
    }
}
}

Мой xaml-файл:

<phone:PhoneApplicationPage
x:Class="app_name.newsummaryPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="#FF03171B" Loaded="newsummaryPage_Loaded">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="1111"/>
        <RowDefinition Height="0*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel Grid.Row="0" Margin="12,0,0,0" Height="116" VerticalAlignment="Top">
        <TextBlock Text="app name" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock Text="New summary" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>
    <Grid x:Name="newsummaryGrid" Margin="0,116,12,370">
        <TextBox x:Name="practiceTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" Width="458" Margin="0,27,0,0" Height="72" VerticalAlignment="Top"/>
        <TextBlock HorizontalAlignment="Left" Margin="10,0,0,0" TextWrapping="Wrap" Text="Enter a new name for your summary:" VerticalAlignment="Top"/>
        <Button x:Name="nextButton" Content="Create the summary" HorizontalAlignment="Left" Margin="0,553,0,0" VerticalAlignment="Top" Width="456" Click="nextButton_Click"/>
        <ListBox x:Name="selectprojectsandsubjectsListBox" Margin="10,99,12,80" SelectionChanged="selectprojectsandsubjectsListBox_SelectionChanged" FontSize="36" Tap="selectprojectsandsubjectsListBox_Tap"/>
    </Grid>

    <!--ContentPanel - place additional content here-->
</Grid>

</phone:PhoneApplicationPage>

Внутреннее исключение:

  • $exception {System.Windows.Markup.XamlParseException: не удалось назначить свойство «System.Windows.UIElement.Tap». [Строка: 32 Позиция: 172] в System.Windows.Application.LoadComponent(компонент Object, Uri resourceLocator) в Knowledge_Organizer.newsummaryPage.InitializeComponent() в Knowledge_Organizer.newsummaryPage..ctor()} System.Exception {System.Windows.Markup .XamlParseException}

person Erik    schedule 05.01.2014    source источник
comment
Проверьте внутреннее исключение на фактическое сообщение об исключении.   -  person Rohit Vats    schedule 05.01.2014
comment
Как проверить внутреннее сообщение об исключении?   -  person Erik    schedule 05.01.2014
comment
В диалоговом окне исключения вы увидите гиперссылку View Details. Он откроет всплывающее окно и увидит в нем внутреннее свойство исключения.   -  person Rohit Vats    schedule 05.01.2014
comment
Извините, если я немного новичок в этом, но я не вижу эту гиперссылку. Если вы имеете в виду окно, которое появляется в vs, тогда возникает исключение - оно говорит только об открытых настройках исключения, перерыве, продолжении и игнорировании, которое я не могу нажать   -  person Erik    schedule 05.01.2014


Ответы (1)


Посмотрите окно вывода, оно обычно содержит полезную информацию о содержимом исключения. введите здесь описание изображения

или когда появится окно исключения, нажмите перерыв и перейдите в меню DEBUG визуальной студии, выберите windows- > locals. исключение должно появиться в представлении местных жителей.

или попробуйте отладить и поймать исключение, чем увидеть его свойства и внутреннее сообщение.

введите здесь описание изображениявведите здесь описание изображения

person MichaelLo    schedule 05.01.2014
comment
теперь добавлен локальный материал, похоже, он не хочет назначать свойство tap - person Erik; 05.01.2014
comment
На самом деле мне удалось исправить ошибку с этим окном. Я немного поэкспериментировал, в итоге скопировал код, изменил имя события касания и заново создал его. Теперь работает идеально! Спасибо! - person Erik; 05.01.2014