wpf 如何设置按钮的内部文本边距

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7982000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 23:09:42  来源:igfitidea点击:

how to set inner text margin of button

wpftextbuttonpaddingmargin

提问by Bogdan Verbenets

I have a WPF button with some text in it. If I don't set button's width manually, then the button width will be almost of text's width, and it doesn't look very good. I don't want to calculate the width of each button. Is there a more convenient way to specify the relative width of the button? For example in CSS you can specify padding or margin. Is there something like that in WPF?

我有一个带有一些文本的 WPF 按钮。如果我不手动设置按钮的宽度,那么按钮的宽度将几乎是文本的宽度,看起来不太好。我不想计算每个按钮的宽度。有没有更方便的方法来指定按钮的相对宽度?例如在 CSS 中,您可以指定填充或边距。WPF中有类似的东西吗?

回答by Rachel

You can set the Button's Padding

您可以设置按钮的 Padding

<Button Content="Test" Padding="5,2" />