0

Windows Phone7 では、いくつかのデータを解析する UserControl を作成しました。現在、そのユーザーコントロールのインスタンスを作成できません。

ユーザーコントロールから解析を削除すると、次のようなエラーが発生しない限り、インスタンスを作成できます

`"Cannot create instance of '<usercontrolname>' 
"XapCannotFindFileInPackage]
Arguments:HelpScreenData.xml 
Debugging Resource String are unavailable.Often the key and
arguments provide sufficient information to diagonise the problem.see
http://go.microsoft.com'/fwlink/?linkid=106663&version5.0.10411.00&
file=system.xml.dll&key=Xml_cannot find file in Xappackage"

私の UserControl CodeBehind

 public partial class ques : UserControl
{
    Popup popup = new Popup();
    tutorial tut = new tutorial();   //another usercontrol

    String[] str;
    String[] nam;
    public ques()
    {
        InitializeComponent();

   }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {

        LayoutRoot.Visibility = Visibility.Visible;

        buy_bac.Visibility = Visibility.Collapsed;
        buy_hme.Visibility = Visibility.Collapsed;
        buy_qestim.Visibility = Visibility.Collapsed;
        buy_piti.Visibility = Visibility.Collapsed;
        buy_qual.Visibility = Visibility.Collapsed;
        buy_rent.Visibility = Visibility.Collapsed;
        buy_rep.Visibility = Visibility.Collapsed;
        buy_mre.Visibility = Visibility.Collapsed;

        if (Modules.Programname == "Buyers")
        {
            buy_bac.Visibility = Visibility.Visible;
            buy_hme.Visibility = Visibility.Visible;
            buy_qestim.Visibility = Visibility.Visible;
            buy_piti.Visibility = Visibility.Visible;
            buy_qual.Visibility = Visibility.Visible;
            buy_rent.Visibility = Visibility.Visible;
            buy_rep.Visibility = Visibility.Visible;
            buy_mre.Visibility = Visibility.Visible;
        }
        XDocument doc = XDocument.Load("HelpScreenData.xml");
        string val = doc.ToString();

        XElement doc1 = doc.Descendants("buyer").First();

        var parsedPlist = doc1.Descendants("row");

        int i = 0;
        str = new string[parsedPlist.Count()];
        nam = new string[parsedPlist.Count()];
        foreach (XElement elem in parsedPlist)
        {
            nam[i] = (string)elem.Element("btn_name");
            str[i] = (string)elem.Element("string");
            i++;
        }
    }
    private void i1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {


        if (nam[0] == buy_bac.Name)
        {


            Modules.msg = str[0];
            if (Modules.msg != null)
            {
                if (popup.IsOpen != true)
                {

                    popup.Child = tut;
                    popup.IsOpen = true;
                    popup.VerticalOffset = 200;
                    popup.HorizontalOffset = 50;
                    popup.IsOpen = true;
                    tut.lb_tut.Text = Modules.msg;
                }
                else
                {
                    popup.IsOpen = false;
                }
            }
            else if (nam[1] == buy_hme.Name)
            {
                Modules.msg = str[1];
                if (Modules.msg != null)
                {
                    if (popup.IsOpen != true)
                    {
                        popup.Child = tut;
                        popup.IsOpen = true;
                        popup.VerticalOffset = 400;
                        popup.HorizontalOffset = 50;
                        popup.IsOpen = true;
                        tut.lb_tut.Text = Modules.msg;
                    }
                    else
                    {
                        popup.IsOpen = false;
                    }
                }

            }
            else if (nam[1] == buy_qestim.Name)
            {
                Modules.msg = str[2];
                if (Modules.msg != null)
                {
                    if (popup.IsOpen != true)
                    {
                        popup.Child = tut;
                        popup.IsOpen = true;
                        popup.VerticalOffset = 400;
                        popup.HorizontalOffset = 50;
                        popup.IsOpen = true;
                        tut.lb_tut.Text = Modules.msg;
                    }
                    else
                    {
                        popup.IsOpen = false;
                    }
                }

            }
        }


    }

    private void i3_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (nam[2] == buy_piti.Name)
        {
            Modules.msg = str[3];
            if (Modules.msg != null)
            {
                if (popup.IsOpen != true)
                {
                    popup.Child = tut;
                    popup.IsOpen = true;
                    popup.VerticalOffset = 600;
                    popup.HorizontalOffset = 50;
                    popup.IsOpen = true;
                    tut.lb_tut.Text = Modules.msg;
                }
                else
                {
                    popup.IsOpen = false;
                }
            }

        }
        else if (nam[2] == buy_rent.Name)
        {
            Modules.msg = str[4];
            if (Modules.msg != null)
            {
                if (popup.IsOpen != true)
                {
                    popup.Child = tut;
                    popup.IsOpen = true;
                    popup.VerticalOffset = 600;
                    popup.HorizontalOffset = 50;
                    popup.IsOpen = true;
                    tut.lb_tut.Text = Modules.msg;
                }
                else
                {
                    popup.IsOpen = false;
                }
            }

        }
        else if (nam[2] == buy_qual.Name)
        {
            Modules.msg = str[5];
            if (Modules.msg != null)
            {
                if (popup.IsOpen != true)
                {
                    popup.Child = tut;
                    popup.IsOpen = true;
                    popup.VerticalOffset = 600;
                    popup.HorizontalOffset = 50;
                    popup.IsOpen = true;
                    tut.lb_tut.Text = Modules.msg;
                }
                else
                {
                    popup.IsOpen = false;
                }
            }

        }
        else if (nam[2] == buy_mre.Name)
        {
            Modules.msg = str[6];
            if (Modules.msg != null)
            {
                if (popup.IsOpen != true)
                {
                    popup.Child = tut;
                    popup.IsOpen = true;
                    popup.VerticalOffset = 600;
                    popup.HorizontalOffset = 50;
                    popup.IsOpen = true;
                    tut.lb_tut.Text = Modules.msg;
                }
                else
                {
                    popup.IsOpen = false;
                }
            }

        }
    }

解析した xml のサンプル

<?xml version="1.0" encoding="utf-8" ?>
<plist version="1.0">
<Main_Screen>
<row>
<btn_name>Buyer Programs</btn_name>
<string>Answer your client’s difficult .</string>
</row>
<row>
<btn_name>Seller’s Programs</btn_name>
<string>What do sellers want s needs.</string>
</row>
</Main_Screen>
 <abssas>
<row>
<btn_name>dat Programs</btn_name>
<string> your client’s </string>
</row>
<row>
<btn_name>my Programs</btn_name>
<string> sellers want s needs.</string>
</row>
</abssas>
</plist>
4

1 に答える 1

0

「HelpScreenData.xml」を読み込もうとしていますが、解決できません。このファイルがプロジェクトの一部として含まれていることを確認してください。

于 2012-07-31T17:08:24.207 に答える