【发布时间】:2015-09-25 22:45:21
【问题描述】:
我在一个单独的库中定义了我的资源字典,如下所示
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cultures="clr-namespace:My_Localization.Cultures"
xmlns:properties="clr-namespace:My_Localization.Properties">
<ObjectDataProvider x:Key="Resources" ObjectType="{x:Type cultures:CultureResources}" MethodName="GetResourceInstance"/>
<ObjectDataProvider x:Key="CultureResourcesDS" ObjectType="{x:Type cultures:CultureResources}"/>
</ResourceDictionary>
我已经从另一个库中使用了这个库,如下所示(仅限 xaml 的标题)
<msRibbon:RibbonTab x:Class="Ribbon.Planner.PlannerRibbon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:msRibbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="500" Header="{Binding Path=Ribbon_About, Source={StaticResource Resources}}"
>
<Grid>
...
...
...
</Grid>
我已经添加了 My_Localization 库的引用,我只是更改了标题。一切正常,但唯一的问题是,在设计时,我在“Header="{Binding Path=Ribbon_About, Source={StaticResource Resources}}" 下划线。当我将鼠标悬停时,提示“资源“资源”不能解决”
为什么我的 xaml 中出现类似提示的错误?那为什么一切正常?
我的解决方案结构
- MainExe - 包含 app.xaml。我在这里合并了资源字典。 xaml 中没有问题,因为 app.xaml 中存在合并字典
- My_Localization - 包含资源字典的库(上面的代码)
- Lib1 - 引用 My_Localization 并且 xaml 中存在问题,如解释
- Lib2 - 引用 My_Localization 并且 xaml 中存在问题,如所述
- Lib3 - 引用 My_Localization 并且 xaml 中存在问题,如所述
【问题讨论】:
-
因为它只在运行时合并字典。
-
我是这么认为的,但是 xaml 显示的设计时间好像有错误是正确的吗?有没有办法防止这种情况发生?