【发布时间】:2015-01-15 03:42:47
【问题描述】:
现在两个文本框和“=”符号位于不同的两行。
像这样:
我喜欢把它们都放在同一行,像这样:
我该怎么做?
【问题讨论】:
标签: c# xaml windows-phone
现在两个文本框和“=”符号位于不同的两行。
像这样:
我喜欢把它们都放在同一行,像这样:
我该怎么做?
【问题讨论】:
标签: c# xaml windows-phone
可以使用简单的水平堆栈面板,但您可能喜欢网格的自动调整大小功能。
<Grid Margin="10,0,10,0">
<StackPanel Orientation="Vertical">
<TextBlock>CONVERTER</TextBlock>
<RadioButton>Area</RadioButton>
<RadioButton>Currency</RadioButton>
<RadioButton>Temperature</RadioButton>
<!--
For specific-sized widths, a simple horizontal stack panel will do,
along with margins to make sure there is padding around the equal sign.
-->
<StackPanel Orientation="Horizontal">
<TextBox Width="150"/>
<TextBlock Text="=" VerticalAlignment="Center"
Margin="10,0,10,0" FontSize="24"/>
<TextBox Width="150"/>
</StackPanel>
<!--
For edit controls that scale based on the screen width,
you can use a grid.
-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="10,0,10,0"
FontSize="24" Text="="/>
<TextBox Grid.Column="2"/>
</Grid>
</StackPanel>
</Grid>
有关如何定义网格列的详细信息,请参阅http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.columndefinition.width.aspx。
【讨论】:
StackPanel 中【讨论】:
有多种方法。您可以使用 stackpanel 或 wrappanel 并使用方向 = 水平。或者您可以使用网格并使用两列并将文本框放在其中。
【讨论】: