“无效的xaml”设计者的错误
我正在尝试使用列表框来显示自定义用户控件。它一直工作得很好,直到最近我开始收到“无效的 xaml”错误消息,并且不再能够刷新设计视图。
该错误不会阻止应用程序编译和运行。
我已经尝试了我能想到的一切。我从头开始创建了一个测试控件和一个测试页,只有当我将控件放入数据模板中时才会出现错误。我可以将任何标准控件放入数据模板中而不会出现错误。仅自定义用户控件上的错误。
这是页面:
<phone:PhoneApplicationPage
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:WP7ListBoxSelectedItemStyle"
xmlns:my="clr-namespace:testproject.Controls"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
x:Class="WP7ListBoxSelectedItemStyle.TestPage"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="8,17,16,-17">
<ListBox Name="lb_test"
Margin="0,0,0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<my:Test1></my:Test1>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
这是用户控件(代码隐藏中没有添加代码):
<UserControl x:Class="testproject.Controls.Test1"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Height="80" Width="80">
<Grid x:Name="LayoutRoot">
</Grid>
</UserControl>
I am trying to use a listbox to display a custom UserControl. It had been working just fine until recently i started recieving an "invalid xaml" error message and am no long able to refresh the Design View.
The error does not keep the app from compiling and running.
I have tried everything i can think of. I created a test control and a test page from scratch and only get the error when i put the control in the data template. I can put any standard control into the data template without error. only errors on a custom usercontrol.
here is the page:
<phone:PhoneApplicationPage
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:WP7ListBoxSelectedItemStyle"
xmlns:my="clr-namespace:testproject.Controls"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
x:Class="WP7ListBoxSelectedItemStyle.TestPage"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="8,17,16,-17">
<ListBox Name="lb_test"
Margin="0,0,0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<my:Test1></my:Test1>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
and here is the usercontrol (no added code in the codebehind):
<UserControl x:Class="testproject.Controls.Test1"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Height="80" Width="80">
<Grid x:Name="LayoutRoot">
</Grid>
</UserControl>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
try:
好的,我根据这篇文章弄清楚了
http://forums.silverlight.net/post/618518 .aspx
我不敢相信我在程序集名称中添加了一个空格。 ARG!
Ok, I figured it out based on this post
http://forums.silverlight.net/post/618518.aspx
I cannot believe I added a space to my assembly name. ARG!