Roc*_*etq 1 c# wpf visual-studio visual-studio-2013
正确的xaml代码看起来像这样:
mc:Ignorable="d" d:DesignWidth="363" Height="628">
<Grid Style="{StaticResource ContentRoot}">
<ScrollViewer Margin="0,-105,-9,0">
<StackPanel MinWidth="200" HorizontalAlignment="Left" Width="474" Height="459">
</InlineUIContainer>
<Run Language="ru-ru"/>
<LineBreak/>
<Run Language="ru-ru" Text="Num1"/>
<LineBreak/>
<InlineUIContainer>
<TextBox d:DesignUseLayoutRounding="True"
Width="160"
UseLayoutRounding="True"
Text="Enter num"
TextWrapping="Wrap"
x:Name="TxtBlock_numRequest"
InputMethod.IsInputMethodEnabled="False"
Height="23"
AutoWordSelection="True"/>
</InlineUIContainer>
<LineBreak/>
<Run Language="ru-ru"/>
<LineBreak/>
<Run Language="ru-ru" Text="ID"/>
<Run Text=" "/>
<LineBreak/>
<InlineUIContainer>
<TextBox Width="160"
Text="Enter num"
TextWrapping="Wrap"
x:Name="TxtBlock_IDWork"
Height="23"/>
Run Code Online (Sandbox Code Playgroud)
你可以有两个文本框,其中一个位于另一个下面,我需要将它们放在同一级别,我尝试通过构造函数,它根本不在我的特定情况下.要清除我添加了图片.
而且不要害怕外国铭文,这无关紧要.

我只是不知道如何解决这个问题,我认为它与此有关StackPanel.有任何想法吗 ?
UPD:这里的所有xaml代码http://snipt.org/Btff4/Default#expand UPD:是否可以再添加一个堆栈面板?
您可能正在寻找Orientation属性:
<StackPanel MinWidth="200" HorizontalAlignment="Left" Width="474" Height="459" Orientation="Horizontal">
Run Code Online (Sandbox Code Playgroud)
更新
添加一个非常基本的示例来说明StackPanel的工作原理:
<Window x:Class="WpfTestBench.Stackpanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" SizeToContent="WidthAndHeight">
<StackPanel Orientation="Horizontal" Margin="10">
<TextBox Text="First textbox" Height="20" Margin="5, 0" />
<TextBox Text="Second textbox" Height="20" />
</StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
执行结果:

更新
添加允许实现所需布局的XAML:
<Window x:Class="WpfTestBench.Stackpanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Sample layout" SizeToContent="Height" Width="400">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.ColumnSpan="3" Grid.Row="0" Content="??????? ????????? ??????" FontWeight="Bold" FontSize="16" />
<Grid Grid.Column="0" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="????? ??????" />
<TextBox Grid.Row="1" Text="??????? ?????" />
<TextBlock Grid.Row="3" Text="????????? ??????" />
<ComboBox Grid.Row="4" SelectedIndex="0">
<ComboBoxItem Content="???????" />
<ComboBoxItem Content="???????" />
<ComboBoxItem Content="??????" />
</ComboBox>
</Grid>
<Grid Grid.Column="2" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="????????????? ???? ??????" />
<TextBox Grid.Row="1" Text="??????? ?????" />
<TextBlock Grid.Row="3" Text="????? ??????????" />
<TextBox Grid.Row="4" Text="??????? ?????" />
</Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
执行结果:

| 归档时间: |
|
| 查看次数: |
3904 次 |
| 最近记录: |