0
我有一个类库,其中包含一个ResourceDictionary
,它包含Styles
。 字典引用Converter
,这是在同一个组件定义,像这样:Style with Converter in other assembly
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:Lib.Resources.Converters">
<converter:TextSizeConverter x:Key="LabelTextSizeConverter" />
<Style TargetType="{x:Type Label}">
<Setter Property="FontSize"
Value="{Binding ActualWidth, RelativeSource={RelativeSource Self}, Converter={StaticResource LabelTextSizeConverter}}" />
</Style>
<ResourceDictionary />
当我尝试加载另一个项目的字典,我得到一个XamlParseException
,指出Converter
类型未知的。
var rd = new ResourceDictionary()
{
Source = new Uri("pack://application:,,,/Lib.Resources;component/Styles/Label.xaml")
};
Resources.MergedDictionaries.Add(rd);
我试过各种BuildActions
没有任何成功的转换器。
有没有办法解决这个问题,还是我需要以完全不同的方式来解决这个问题?
你loook到这一点:http://msdn.microsoft.com/en-US/library/vstudio/aa970069.aspx? – Florian
你能分享你如何合并被引用的字典吗? – Nitin
@nit:我添加了一些代码。 – nuke