加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 01:41:18 所属栏目:百科 来源:网络整理
导读:我在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.Resour
我在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>

生成错误的示例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>

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

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

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

有什么建议?

提前致谢,
kruvi

解决方法

将App.xaml的Build Action设置为ApplicationDefinition 将App.xaml从一个项目复制到另一个项目时经常会出现错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读