将角半径添加到后面代码中的按钮

时间:2018-04-12 07:55:49

标签: c# wpf

我想在c#代码中为按钮添加转角半径。当我跑步时,所有的屁股都消失了。欢迎任何帮助或提示

Style s = new Style(typeof(Button));
ControlTemplate control = new ControlTemplate(typeof(Button));
control.VisualTree = new FrameworkElementFactory(typeof(Border));
control.VisualTree.SetValue(Border.CornerRadiusProperty, new CornerRadius(10));
s.Setters.Add(new Setter(Button.TemplateProperty,control));

1 个答案:

答案 0 :(得分:0)

尝试将ContentPresenter添加到边框:

elemFactory.AppendChild(new FrameworkElementFactory(typeof (ContentPresenter)));