其他分享
首页 > 其他分享> > WPF border圆角CornerRadius的绑定

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

标签:string,DependencyProperty,Thickness,Radius,CornerRadius,WPF,border,public,Radius
来源: https://www.cnblogs.com/GongJx/p/15213134.html