gpt4 book ai didi

Xaml无法创建 "X"的实例

转载 作者:行者123 更新时间:2023-12-04 18:14:47 24 4
gpt4 key购买 nike

我试图在Windows Phone 7中为我的应用程序创建一个“设置”页面。我创建了AppSettings类,并从MainPage.xaml引用它。这是我的代码:

<phone:PhoneApplicationPage 
x:Class="Shapes4Kids.MainPage"
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"
xmlns:local="clr-namespace:ShapesSettings;assembly=Shapes4Kids"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<local:AppSettings x:Key="appSettings"></local:AppSettings>
</phone:PhoneApplicationPage.Resources>

但是在引用AppSettings的行(local:AppSettings行)上,我收到一条错误消息,指出“无法创建AppSettings实例”。

最佳答案

这是因为实例化ApplicationsSettings会引发异常。如果将以下内容添加到构造函数中,就可以了;

try
{
settings = IsolatedStorageSettings.ApplicationSettings;
}
catch (System.IO.IsolatedStorage.IsolatedStorageException e)
{
// handle exception
}

关于Xaml无法创建 "X"的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5851767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com