How to set the zindex of datatemplate's in a longlistselector
Asked Answered
D

1

6

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>
Demission answered 3/3, 2014 at 15:46 Comment(0)
S
1

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>   
Scot answered 18/9, 2014 at 21:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.