初始化组件WP8时发生XamlParseException
正如标题所说,当我尝试运行应用程序时,会出现一个XamlParseException。我刚刚开始学习xaml,目前正在学习一本名叫《WindowsPhone8游戏开发》的书中的教程,这是它给我的一个例外 发生System.Windows.Markup.XamlParseException异常 HResult=-2146233087 Message=多次设置属性“System.Windows.Controls.Panel.Children”。[第53行位置:74] Source=System.Windows 行号=53 LinePosition=74 堆栈跟踪: 位于System.Windows.Application.LoadComponent(对象组件,Uri resourceLocator) 在SpaceAim3D.Views.MenuPage.InitializeComponent()中 在SpaceAim3D.Views.MenuPage..ctor()中 内部异常: 这是我的密码初始化组件WP8时发生XamlParseException,xaml,windows-phone-8,xamlparseexception,Xaml,Windows Phone 8,Xamlparseexception,正如标题所说,当我尝试运行应用程序时,会出现一个XamlParseException。我刚刚开始学习xaml,目前正在学习一本名叫《WindowsPhone8游戏开发》的书中的教程,这是它给我的一个例外 发生System.Windows.Markup.XamlParseException异常 HResult=-2146233087 Message=多次设置属性“System.Windows.Controls.Panel.Children”。[第53行位置:74] Source=System.Wi
public partial class MenuPage : PhoneApplicationPage
{
private Dictionary<String, String> m_urls = new Dictionary<string, string>();
public MenuPage()
{
InitializeComponent();
m_urls["play"] = "/Views/GamePage.xaml";
m_urls["ranks"] = "/Views/RanksPage.xaml";
m_urls["map"] = "/Views/MapPage.xaml";
m_urls["world"] = "/Views/WorldPage.xaml";
m_urls["help"] = "/Views/HelpPage.xaml";
m_urls["web"] = "/Views/WebPage.xaml";
m_urls["settings"] = "/Views/SettingsPage.xaml";
}
//This is a common event handler used by all entities on menu page
private void BrdPage_Tap(object sender, GestureEventArgs e)
{
//To get the tag name we case the sender object and get the tag as a string
String page = ((Border)sender).Tag as String;
NavigationService.Navigate(new Uri(m_urls[page], UriKind.Relative));
}
}
公共部分类菜单页面:PhoneApplicationPage
{
私有字典m_URL=新字典();
公共菜单页()
{
初始化组件();
m_URL[“play”]=“/Views/GamePage.xaml”;
m_URL[“排名”]=“/Views/RanksPage.xaml”;
m_url[“map”]=“Views/MapPage.xaml”;
m_URL[“世界”]=“/Views/WorldPage.xaml”;
m_URL[“帮助”]=“/Views/HelpPage.xaml”;
m_URL[“web”]=“/Views/WebPage.xaml”;
m_URL[“设置”]=“/Views/SettingsPage.xaml”;
}
//这是菜单页面上所有实体使用的通用事件处理程序
私有void BrdPage_轻触(对象发送者、GestureEventArgs e)
{
//为了获得标记名,我们对发送者对象进行大小写,并将标记作为字符串
字符串页=((边框)发件人)。标记为字符串;
NavigationService.Navigate(新Uri(m_URL[page],UriKind.Relative));
}
}
这是我的Xaml代码
<phone:PhoneApplicationPage
x:Class="SpaceAim3D.Views.MenuPage"
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="Landscape" Orientation="Landscape"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="125" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/Assets/asteroid.png" />
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBlock" x:Key="ButtonText">
<Setter Property="FontSize" Value="40"/>
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</phone:PhoneApplicationPage.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0"
Style="{StaticResource PhoneTextTitle1Style}">
Space Aim <Bold>3D</Bold>
</TextBlock>
<Grid.Background>
<ImageBrush ImageSource="/Assets/background.png" />
</Grid.Background>
<Border Grid.Row="1" Margin="10,5,536,194" Tap="BrdPage_Tap" Tag="play">
<TextBlock Style="{StaticResource ButtonText}" Text="PLAY!"/>
</Border>
<Border Margin="255,74,291,221" Grid.RowSpan="2" Tap="BrdPage_Tap" Tag="ranks">
<TextBlock Style="{StaticResource ButtonText}" Text="RANKS!" Margin="12,66,10,66" Width="160"/>
</Border>
<Border Grid.Row="1" Margin="12,162,534,37" Tap="BrdPage_Tap" Tag="map">
<TextBlock Style="{StaticResource ButtonText}" Text="MAP"/>
</Border>
<Border Grid.Row="1" Margin="238,189,308,10" Tap="BrdPage_Tap" Tag="world">
<TextBlock Style="{StaticResource ButtonText}" Text="WORLD"/>
</Border>
<Border Grid.Row="1" Margin="420,76,126,123" Tap="BrdPage_Tap" Tag="web">
<TextBlock Style="{StaticResource ButtonText}" Text="WEB"/>
</Border>
<Border Grid.Row="1" Margin="556,148,-10,51" Tap="BrdPage_Tap" Tag="help">
<TextBlock Style="{StaticResource ButtonText}" Text="HELP"/>
</Border>
<Border Margin="503,54,12,241" Grid.RowSpan="2" Tap="BrdPage_Tap" Tag="settings">
<TextBlock Style="{StaticResource ButtonText}" Text="SETTINGS"/>
</Border>
</Grid>
</phone:PhoneApplicationPage>
空间目标3D
我将所有带有边框标记的xaml代码移到了grid.background上,它成功了