gpt4 book ai didi

wpf - 在 WPF 控件之间添加空格

转载 作者:行者123 更新时间:2023-12-02 07:31:56 25 4
gpt4 key购买 nike

我使用以下 XAML 代码创建了两个按钮。

<Button x:Name="Button1" Width="100" Content="Button1" HorizontalAlignment="Left" VerticalAlignment="Top" ></Button>
<Button x:Name="Button2" Width="100" Content="Button2" HorizontalAlignment="Left" VerticalAlignment="Top" ></Button>

两个按钮紧紧地接触在一起。如何在它们之间留一些空间?

注意: 按钮位于水平方向的堆栈面板内。

最佳答案

如果您不使用(由于某种原因)按钮的 Margin 属性,您可以在控件(您的情况下为按钮)之间放置具有所需宽度(或/和高度)的透明分隔符(透明背景色)。

在 xaml 中:

<StackPanel Orientation="Horizontal">
<Button x:Name="Button1" Width="100" Content="Button1"/>
<Separator Width="20" Background="Transparent"/>
<Button x:Name="Button2" Width="100" Content="Button2"/>
</StackPanel>

关于wpf - 在 WPF 控件之间添加空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6008001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com