Здравствуйте, я использую прикрепленные свойства внутри шаблона ContentControl. Мой подход до сих пор является this-Использование преобразователей с шаблономсвязывания или родственного шаблона шаблона
Класс с Attached собственности
public class PlaceHolderForProfilePic : DependencyObject
{
public static readonly DependencyProperty InitialsProperty = DependencyProperty.RegisterAttached("Initials", typeof(string), typeof(PlaceHolderForProfilePic), new PropertyMetadata(""));
public static string GetInitials(DependencyObject d)
{
return (string)d.GetValue(InitialsProperty);
}
public static void SetInitials(DependencyObject d, string value)
{
d.SetValue(InitialsProperty, value);
}
}
управления Шаблон Декларация
<ContentControl helpers:PlaceHolderForProfilePic.Initials="{Binding FullName,Converter={StaticResource placeholderConverter},ConverterParameter=initials}" Width="60" Height="60" Template="{StaticResource DefaultProfilePictureItemTemplate2}"/>
Шаблон управления кузовным
<ControlTemplate x:Key="DefaultProfilePictureItemTemplate2">
<Grid Name="parentGrid">
<TextBlock Text="{TemplateBinding helpers:PlaceHolderForProfilePic.Initials}" />
</Grid>
</ControlTemplate>
Теперь я хочу применить конвертер ВНУТРИ тела шаблона, а не в декларации. Я знаю, что TemplateBinding не принимает конвертеры, поэтому я попытался использовать RelativeSource шаблонного Родитель как this-
<TextBlock Text="{Binding helpers:PlaceHolderForProfilePic.Initials , RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource placeholderConverter}, ConverterParameter=initials}"/>
Но есть ошибка BindingPathExpression как он не принимает «:»
Есть ли другой способ решить это?