1
У меня есть DependenyProperty
:WPF Привязать к DependenyProperty
public static readonly DependencyProperty SelectedBackgroundProperty = DependencyProperty.Register("SelectedBackground", typeof(Brush), typeof(CustomizedMetroTabItem), new UIPropertyMetadata(null));
public Brush SelectedBackground
{
get { return (Brush)GetValue(SelectedBackgroundProperty); }
set { SetValue(SelectedBackgroundProperty, value); }
}
Я хочу связать свою Background
свойство к значению SelectedBackgroud DependenyProperty
, так что я сделал следующее:
<Setter Property="Background" Value="{Binding SelectedBackground, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
Я также пробовал
<Setter Property="Background" Value="{TemplateBinding SelectedBackground}"/>
Но это не работает, почему? (Конечно, я установил SelectedBackground из XAML)
Черт, это было просто, спасибо. – Ron