首页 > Windows开发 > 详细

WPF border圆角CornerRadius的绑定

时间:2021-09-01 18:03:21      阅读:13      评论:0      收藏:0      [点我收藏+]

错误写法:

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的绑定

原文:https://www.cnblogs.com/GongJx/p/15213134.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!