WPF border圆角CornerRadius的绑定

错误写法:

public Thickness Radius
{
get { return (Thickness)GetValue(RadiusProperty); }
set { SetValue(RadiusProperty, value); }
}
public static readonly DependencyProperty RadiusProperty =
DependencyProperty.Register("Radius", typeof(Thickness), typeof(CheckButton), new PropertyMetadata(new Thickness(0)));

正确写法

public string Radius
{
get { return (string)GetValue(RadiusProperty); }
set { SetValue(RadiusProperty, value); }
}
public static readonly DependencyProperty RadiusProperty =
DependencyProperty.Register("Radius", typeof(string), typeof(CheckButton), new PropertyMetadata("0"));

前台border

<Border BorderBrush="#31669A" CornerRadius="{Binding Radius}" Background="#31669A" BorderThickness="1"  />

搞不太懂为什么要用string而不是Thickness

上一篇:Java设计模式——桥接模式


下一篇:Effective-Java-3rd 22-23Item