将DependencyProperty的默认值绑定到动态或静态资源

问题描述 投票:0回答:1

hi,我已经创建了一个依赖项属性,现在我想为其设置默认画笔(当前:透明),但是我想绑定到静态或动态资源。这是我的代码

public static readonly DependencyProperty SideBrushProperty = DependencyProperty.RegisterAttached(
            "SideBrush", typeof(Brush), typeof(ImageRadioButton), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.Inherits));

我该怎么做?

c# wpf dependency-properties
1个回答
1
投票

在您的ctor中设置默认值

public ImageRadioButton(){

SideBrush = Brushes.Red;
}
© www.soinside.com 2019 - 2024. All rights reserved.