slowhand
2021-01-13 10:07:50 +08:00
找了一下自己以前用过的方法,类似这样。
public static readonly DependencyProperty TitleBackgroundProperty =
DependencyProperty.Register("TitleBackground", typeof(Brush), typeof(ButtonIcon), new PropertyMetadata(Brushes.Black));
/// <summary>
/// 标题背景
/// </summary>
public Brush TitleBackground
{
get { return (Brush)GetValue(TitleBackgroundProperty); }
set { SetValue(TitleBackgroundProperty, value); }
}
<Border Grid.Row="1" Background="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path= TitleBackground}"/>