【发布时间】:2011-12-22 13:41:53
【问题描述】:
我的环境是windows phone 7.1。
我有以下代码:
<ListBox ItemsSource="{Binding Path=Items}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="Black" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas Width="200" Height="400"
Canvas.Top="400"> <====== This is not working
... Some content ...
</Canvas>
</DataTemplate>
</ListBox.ItemTemplate>
有一个ListBox 有一个Canvas 作为ItemsPanel。
ListBoxItems 本身也是Canvas 类型。对于我设置了Canvas.Top =400 的ListBoxItems,我希望这些项目在ItemsPanel 中以400 的偏移量显示。
不幸的是,这不起作用,项目在偏移量 0 处呈现,如图所示(ItemsPanel 是黑色,彩色矩形是一个列表项):
为什么ListBoxItems 没有在偏移量 400 处呈现?
【问题讨论】:
标签: c# silverlight windows-phone-7 canvas