【发布时间】:2020-12-22 10:25:41
【问题描述】:
我正在编写我的第一个 UWP 应用程序,我遇到的问题是我想从 C# 代码生成按钮,以便在需要时动态生成它们。在 Xaml 代码中,对齐是通过以下方式完成的:
RelativePanel.AlignLeftWithPanel="True"
(<Button x:Name="Button1" Content="Button" FontSize="50" FontFamily="Muli" RelativePanel.AlignLeftWithPanel="True" Height="250" Width="450" Margin="30" Background="#9cccd2"/>).
现在,当我尝试使用 Code 时,有 Button.HorizontalAlignment = HorizontalAlignment.Right; 选项。但这并没有将我的按钮与相关面板的右侧对齐,它似乎没有任何改变,按钮仍然出现在左侧。
有没有办法通过代码对齐我的按钮而无需指定确切的位置?
提前感谢您的帮助。
【问题讨论】: