的同一XAML文件
我在我的app.xaml中声明了一些转换器。
<Application.Resources>
<ResourceDictionary>
<conv:PhotoParamsConverter x:Key="PhotoParamsConverter" />
.
.
.
.
</ResourceDictionary>
</Application.Resources>
如果我在UserControl中使用它,它可以正常工作,
<Rectangle RenderTransformOrigin="0.5,0.5">
<Rectangle.Fill>
<ImageBrush Stretch="UniformToFill" RenderOptions.BitmapScalingMode="HighQuality">
<ImageBrush.ImageSource>
<MultiBinding Converter="{StaticResource PhotoParamsConverter}">
<Binding Path="Personne.ADH_PHOTO" />
<Binding Path="Personne.ADH_GENDER" />
</MultiBinding>
</ImageBrush.ImageSource>
</ImageBrush>
</Rectangle.Fill>
</Rectangle>
但是在自定义控件(generic.xaml)中,我得到了一个例外:
找不到staticresource photoparamsconverter等
欢迎任何想法
谢谢!
自定义控件是可重复使用的控件,可用于各种非相关项目。在自定义控件本身中引用组件,它肯定会起作用。
您可以改用DynamicResource,或将转换器解析移至与自定义控件