如何在longlistselector中设置数据模板的zindex

问题描述 投票:6回答:1

我有一个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>
canvas z-index datatemplate longlistselector
1个回答
1
投票

我只使用过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>   
© www.soinside.com 2019 - 2024. All rights reserved.