本文介绍了代码后边的按钮边框粗细的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对wpf还是很陌生,现在我正在使用按钮,因此我想更改按钮的边框粗细,但是要从XAML后面的代码中删除,接下来要做的是:
I am very new to wpf, and right now I am working with buttons, and so I want to change buttons border thickness, but from code behind not in XAML, and what I did was next:
var converter = new System.Windows.Media.BrushConverter();
var brush = (Brush)converter.ConvertFromString("#83D744");
btn0.Background = System.Windows.Media.Brushes.Transparent; // This is applied to button
btn0.BorderThickness = new Thickness(1); //Thickness wont apply to button I dont know why
btn0.BorderBrush = brush; //This is also applied to button
推荐答案
按钮"的默认边框粗细为1,因此如果将其设置为1,则不会有任何改变.
The default border thickness for Buttons is 1 so nothing will change if you set it to 1.
要查看更改,只需将其设置为其他内容即可:
To see a change just set it to something different:
button.BorderThickness = new Thickness(1, 1, 1, 3);
这篇关于代码后边的按钮边框粗细的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!