C# 在其他部件中使用转换器的样式

C# 在其他部件中使用转换器的样式,c#,wpf,C#,Wpf,我有一个类库,它包含一个资源字典,其中包含一些样式。 字典引用了在同一程序集中定义的转换器,如下所示: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converte

我有一个类库,它包含一个
资源字典
,其中包含一些
样式
。 字典引用了在同一程序集中定义的
转换器,如下所示:

<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 />
我为转换器尝试了各种
BuildActions
,但没有成功


是否有办法解决此问题,或者我需要以完全不同的方式处理此问题?

您必须将
程序集添加到转换器
xmlns

xmlns:converter="clr-namespace:Lib.Resources.Converters;assembly=YOUR Assembly"

您是否了解此内容:?您可以分享您合并引用词典的方式吗?@nit:我添加了一些代码。请确保您的资源词典的buildaction是resource,并尝试在您的应用程序中执行此操作。xaml Resources
hmm。。。您能否尝试在xmlns converter
xmlns:converter=“clr namespace:Lib.Resources.Converters;assembly=您的程序集”中提供程序集
xmlns:converter="clr-namespace:Lib.Resources.Converters;assembly=YOUR Assembly"