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

WPF border圆角CornerRadius的绑定

上一篇:转 C#开发微信门户及应用(2)--微信消息的处理和应答


下一篇:微信公众帐号开发教程第7篇-各种消息的接收与响应