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

徘徊边缘 提交于 2019-12-19 07:18:08

问题


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 bellow:

  <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>

Thanks in advance,


回答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>   


来源:https://stackoverflow.com/questions/22151071/how-to-set-the-the-zindex-of-datatemplates-in-a-longlistselector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!