我有一个长列表选择器,其中包含我添加到此长列表选择器中的某些图像。 我还更改了该图像的边距,使图像向上或向下等等。 但我想将此图像放在此长列表选择器中的另一图像之前。我尝试过使用 Canvas.Zindex 。 我尝试过将其设置在网格级别、图像级别和 longlistselector 的顶层。() 但它仍然不起作用。有人有一些想法吗?您可以在下面找到我的代码:
<phone:LongListSelector
x:Name="SouthLongListselector"
VerticalAlignment="Bottom"
ItemsSource="{Binding Cards}"
Canvas.ZIndex="{Binding Layer}"
SelectionChanged="SouthLongListselector_SelectionChanged"
LayoutMode="Grid"
GridCellSize="50,200"
Margin="0,0,0,-26"
>
<phone:LongListSelector.ItemTemplate >
<DataTemplate>
<Grid
Background="Transparent"
Margin="{Binding GridOffset}"
Height="150"
Width="110"
>
<!-- add image here-->
<Image
Source="{Binding Image}"
>
</Image>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
最佳答案
我只用过WPF,但xaml应该是一样的。
我没有看到您在任何地方引用的 Canvas,所以 Canvas.ZIndex。所以我认为你想要的是将列表的面板设置为 Canvas ,然后设置列表中时间的 Zindex 。
<phone:LongListSelector.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</phone:LongListSelector.ItemsPanel>
<phone:LongListSelector.ItemTemplate >
<DataTemplate>
<Grid
Canvas.ZIndex"{Binding Layer}"
Background="Transparent"
Margin="{Binding GridOffset}"
Height="150"
Width="110"
>
<!-- add image here-->
<Image
Source="{Binding Image}"
>
</Image>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
关于canvas - 如何在长列表选择器中设置数据模板的 z 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22151071/