小编Mik*_* S.的帖子

从Silverlight中的不同ResourceDictionary引用ResourceDictionary中的资源

我在App.xaml中有以下代码集:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Client.Common;component/Theme/Brushes.xaml"/>
            <ResourceDictionary Source="/Client.Common;component/Theme/Fonts.xaml"/>
            <ResourceDictionary Source="/Client.Common;component/Theme/CoreStyles.xaml"/>
            <ResourceDictionary Source="/Client.Common;component/Theme/SdkStyles.xaml"/>
            <ResourceDictionary Source="/Client.Common;component/Theme/MyAppName.xaml"/>

            <ResourceDictionary Source="/Client.Common;component/Controls/NavigationPanel.xaml"/>
         </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

NavigationPanel.xaml包含了风格,看起来像这样:

<Style x:Key="NavigationPanelListBox" TargetType="ListBox">
    <Setter Property="Background" Value="{StaticResource DarkBackground}" />
    <Lots of XAML>
</Style>
Run Code Online (Sandbox Code Playgroud)

{StaticResource的DarkBackground}在定义Brushes.xaml文件(即,第一资源字典).它被定义为

<SolidColorBrush x:Key="DarkBackground" Color="#FF707176" />
Run Code Online (Sandbox Code Playgroud)

在资源字典中.

在运行时,我收到以下错误:

Cannot find a Resource with the Name/Key DarkBackground [Line: 16 Position: 44]
Run Code Online (Sandbox Code Playgroud)

行号和位置引用app.xaml中的NavigationPanel.xaml资源字典.

我可以从其他控件引用画笔,而不是包含的资源字典.

为什么我不能引用或为什么它不解析对合并资源字典的层次结构更高的资源的引用?我在这里错过了什么?

c# silverlight xaml resourcedictionary mergeddictionaries

13
推荐指数
2
解决办法
2万
查看次数

是否有一种灵活的方式来部署我的silverlight应用程序并以编程方式更改设置?

我对Web开发很新.我正处于部署阶段(用于测试).我有几个地方(可能是4个地方),我必须在应用程序中添加一个非相对的URI.所以现在,在部署时,需要对其进行更改.

有一种光滑的处理方式吗?通过光滑我的意思是不要手动浏览应用程序并更改URI或一揽子查找和替换(风险太大).我现在只有4个地方需要更改,但这很容易改变并导致部署问题.

我正在使用Microsoft技术堆栈.Silverlight,ASP.NET,RIA等.开发在Visual Studio 2010中完成.

我注意到web项目对web.config有一个很好的转换......这很好.Silverlight资源是否有相同的机制?还有其他方法吗?

有什么想法吗?

c# asp.net deployment silverlight visual-studio-2010

5
推荐指数
1
解决办法
195
查看次数