I have a longlistselector with certain images that i add in this longlistselector. I also change the margins of this image to make the image go up or down and so on. But i want to put this image infront of another image in this longlistselector. I have tried using Canvas.Zindex. I have tried setting it at the grid level, at image level and at the top level of of the longlistselector.() But it still doesn't work. Does anybody have some idea's? You can find my code below:
<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>
Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky) and flex items (elements that are direct children of display: flex elements). Here we see that an element with greater stack order is always above an element with a lower stack order:
Definition and Usage. The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order. Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky). Default value:
An element with greater stack order is always in front of an element with a lower stack order. Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky) and flex items (elements that are direct children of display:flex elements).
You most probably don't need z-index to do that. You can use relative and absolute positioning. I advise you to take a better look at css positioning and the difference between relative and absolute positioning... I saw you're setting position: absolute; to an element and trying to float that element.
I have only used WPF but xaml should be the same.
I don't see your Canvas the you are referencing anywhere so Canvas.ZIndex. So I think what you want is to set the panel of the list to be a canvas and then set the Zindex for the times in the list.
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With