如何在longlistselector中设置datatemplate的zindex [英] How to set the zindex of datatemplate's in a longlistselector

查看:57
本文介绍了如何在longlistselector中设置datatemplate的zindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个longlistselector,其中包含某些要添加到此longlistselector中的图像。
我还更改了此图像的边距以使图像向上或向下等等。
但是我想将此图像放在此longlistselector中的另一图像之前。我尝试使用Canvas.Zindex。
我尝试将其设置在longlistselector的网格级别,图像级别和顶层。()但它仍然无法正常工作。有人有主意吗?您可以在下面找到我的代码:

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>


推荐答案

我只用过WPF,但xaml应该相同

I have only used WPF but xaml should be the same.

我看不到您的Canvas,因此您引用的是Canvas.ZIndex。因此,我认为您想要的是将列表的面板设置为画布,然后为列表中的时间设置Zindex。

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>   

这篇关于如何在longlistselector中设置datatemplate的zindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆