Silverlight:无法解析资源{0}(仅限设计时)

kru*_*uvi 3 c# silverlight xaml

我在VS2010中创建了一个新的silverlight 4项目.

我的App.xaml文件如下:

<Application 
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            x:Class="ZCall.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/Styles.xaml"/>
                <ResourceDictionary Source="Resources/ObjectResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>                        
        </ResourceDictionary>
    </Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)

生成错误的示例xaml视图是:

<UserControl x:Class="ZCall.View.Control.CDetailsControl"
    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"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"  
    mc:Ignorable="d">

    <Grid x:Name="LayoutRoot" Background="White">
        <toolkit:BusyIndicator x:Name="biCDetails" BusyContent="Busy...">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="10"/>
                    <RowDefinition/>
                    <RowDefinition Height="10"/>
                    <RowDefinition/>
                    <RowDefinition Height="10"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"/>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition Width="150"/>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition Width="170"/>
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Orientation="Horizontal">
                    <TextBlock Text="Name:" Style="{StaticResource PatientLabel}"/>
                    <TextBlock x:Name="txtName" Style="{StaticResource PatientData}"/>
                </StackPanel>


            </Grid>
        </toolkit:BusyIndicator>

    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

我在PatientLabel和PatientData资源上都得到了错误.

我的style.xaml文件位于项目根目录的Resources文件夹中.

我的问题是,在设计时,我没有识别styles.xaml中定义的样式,并且我为每个使用的样式都收到错误"资源无法解析",而在运行时,所有样式都被解析并显示为它应该是.

有什么建议?

提前谢谢,克鲁维

小智 5

将App.xaml的Build Action设置为ApplicationDefinition当您将App.xaml从一个项目复制到另一个项目时,通常会发生错误.