C# 如何解决;发生XamlParseException“异常”;在WindowsPhone8中?
我正在开发WindowsPhone8应用程序 我尝试使用为我的WP 8应用程序添加一个通用样式表 我尝试以下步骤-: 步骤1:添加一个新的文本文件,并使用扩展名.xaml[C# 如何解决;发生XamlParseException“异常”;在WindowsPhone8中?,c#,xaml,c#-4.0,windows-phone-8,C#,Xaml,C# 4.0,Windows Phone 8,我正在开发WindowsPhone8应用程序 我尝试使用为我的WP 8应用程序添加一个通用样式表 我尝试以下步骤-: 步骤1:添加一个新的文本文件,并使用扩展名.xaml[样式表.xaml] Stylessheet.xamlcode forTextBoxStyle <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://s
样式表.xaml
]
Stylessheet.xaml
code forTextBox
Style
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Style x:Name="Textblockstyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Red"></Setter>
<Setter Property="FontWeight" Value="ExtraBold"></Setter>
</Style>
</ResourceDictionary>
步骤3:mainpage.xaml
apply syle fortextBlock
<TextBlock Name="txtblock" Style="{StaticResource Textblockstyle}">Hi this is for sample</TextBlock>
由于这条线而出现问题
此代码中存在什么问题
<TextBlock Name="txtblock2" Margin="0,50,0,0">This is second sample</TextBlock>
<TextBlock Name="txtblock3" Margin="0,100,0,0," Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>
这是第二个示例
最终样本文本
存在Margin=“0100,0,0”时发生错误
删除此页边距后。代码正确运行。这个代码有什么问题 从合并词典的ResourceDictionary中的Source属性中删除正斜杠: …Source=“Stylessheet.xaml” 而不是
…Source=“/Stylessheet.xaml”…从合并词典的ResourceDictionary中的Source属性中删除正斜杠: …Source=“Stylessheet.xaml” 而不是
…Source=“/Stylessheet.xaml”…您的样式表工作正常,问题在下面一行
<TextBlock Name="txtblock3" Margin="0,100,0,0," Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>*
最终示例文本*
边距加了一个逗号
<TextBlock Name="txtblock3" Margin="0,100,0,0" Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>
最终示例文本
您的样式表工作正常,问题在下面一行
<TextBlock Name="txtblock3" Margin="0,100,0,0," Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>*
最终示例文本*
边距加了一个逗号
<TextBlock Name="txtblock3" Margin="0,100,0,0" Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>
最终示例文本
经过一番讨论后,发现问题是由页边距中的一个附加逗号引起的:
<TextBlock Name="txtblock3" Margin="0,100,0,0," Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>
最终示例文本
经过一番讨论后,发现问题是由页边距中的一个附加逗号引起的:
<TextBlock Name="txtblock3" Margin="0,100,0,0," Style="{StaticResource Textblockstyle}">Final sample Text</TextBlock>
最终示例文本
It show me error查找资源字典“Stylessheet.xaml”时出错文件的生成操作设置为什么(右键单击文件=>properties),文件的相对位置是什么?生成操作应设置为“Page”,stylessheet.xaml和mainpage都应设置为“Page”。xaml生成操作属性仅为Page,因此必须有其他未显示的内容。这可以正常工作。它向我显示错误查找资源字典“Stylessheet.xaml”时出错。文件的生成操作设置为什么(右键单击文件=>properties),文件的相对位置是什么?生成操作应设置为“Page”,stylessheet.xaml和mainpage都应设置为“Page”。xaml生成操作属性仅为Page,因此必须有其他未显示的内容。这是没有问题的。Source=“/Stylessheet.xaml”是正确的文件路径??但是我删除了“/”它显示在查找资源字典“Stylessheet.xaml”时发生了错误。现在我添加我的文件结构图像供您参考。@gurunahan我根据您的代码构建了一个简单的示例,它运行良好。也许你在App.xaml中的其他地方有错误?@gurunahan如果问题解决了,请将答案标记为已接受。我认为Romasz应该添加他的答案,让您将其标记为已接受。Source=“/Stylessheet.xaml”是正确的文件路径??但我删除了“/”它表明在查找资源字典“Stylessheet.xaml”时发生了错误JaiHind现在我添加我的文件结构图像供您参考。@Gurunahan我根据您的代码构建了一个简单的示例,运行良好。也许你在App.xaml中的其他地方有错误?@gurunahan如果问题解决了,请将答案标记为已接受。我认为罗马兹应该加上他的答案,让你把它标记为接受。