[英]How can I change a Listbox's' DataTemplate orientation at runtime?
I am recently trying to learn WinRT and Xaml, and I stumbled upong this issue: 我最近正在尝试学习WinRT和Xaml,我偶然发现了这个问题:
I have this fragment of code: 我有这段代码:
<ListBox Grid.Row="1" x:Name="imageListBox" Height="721">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="imageListBoxStackPanelTemplate" HorizontalAlignment="Center">
<Image Source="{Binding url}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
which is bound to an ObservableCollection, and displays the images vertically. 绑定到ObservableCollection,并垂直显示图像。 I'd like to be able to change the orientation (the flow direction) of the images from Vertical to Horizontal upong pressing a Button, at runtime.
我希望能够在运行时按下按钮将图像的方向(流向)从垂直更改为水平。
I've tried several solutions without any luck, so I hope someone of you could lend me an hand. 我已经尝试了几个没有运气的解决方案,所以我希望你们中的某个人可以伸出援助之手。 Thanks!
谢谢! :)
:)
You can use two listbox, having different orientation. 您可以使用两个具有不同方向的列表框。 One is visible another collapsed.
一个是可见的另一个崩溃。 Click on the button swap the visibility.
单击按钮交换可见性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.