Eme*_*llo 2 wpf datatemplate itemscontrol orientation
我已经研究了很长时间了,找不到答案.
如何并排显示我的itemscontrol中的每个项目?
以下代码并排显示每个项目的内容(标签和文本框),但下一个项目显示在下面.假设我的ItemsControl中有3个项目.目前的行为是:
标签文本框
标签文本框
标签文本框
我想要的是:
标签文本框标签文本框标签文本框(并排)
当前代码使用堆栈面板将方向设置为水平(这就是标签和文本框并排的原因).但我需要一些属性或技术来将itemscontrol内容方向设置为水平.我的代码:
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Name="pnlText" Orientation="Horizontal" Width="750">
<Label Content="{Binding ParameterDisplayName, Mode=OneWay}" />
<TextBox Name="txtText" HorizontalAlignment="Left" Text="{Binding ParameterValue, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Visibility="{Binding ParameterType, Converter={StaticResource ParameterTypeToVisibilityConverter}, ConverterParameter=Text}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
有谁知道这是怎么做到的吗?
谢谢!
您应该为您的ItemsControl:设置此属性:
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2922 次 |
| 最近记录: |