我有一个longlistselector,其中包含某些要添加到此longlistselector中的图像。我还更改了该图像的边距,以使图像向上或向下等等。但是我想将此图像放在此longlistselector中的另一个图像之前。我尝试使用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。因此,我认为您想要的是将列表的面板设置为画布,然后为列表中的时间设置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>