在Windows Phone c#中显示像图片库一样的图像交换

本文关键字:一样 交换 图像 图片库 Phone Windows 显示 | 更新日期: 2023-09-27 18:11:02

我不能像windows phone中的图片库那样流畅地交换。

我尝试了flip gesture listener,它能够交换图像,但不能顺利交换。

我试着搜索,但没有得到任何答案。我试图显示在画廊查看方式的图像列表。我在过去的3天里一直在挣扎。如果你给我一些建议或链接,这将是一个帮助。

在Windows Phone c#中显示像图片库一样的图像交换

这是我刚刚建立的一个简单的例子,向您展示如何完成它。希望对你有帮助

<phone:PhoneApplicationPage xmlns:Controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"  
x:Class="PhotoChooser.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>
    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ListBox x:Name="lbImages">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Controls:Panorama>
                        <Controls:PanoramaItem>
                            <Image Source="{Binding ImageName}"/>
                        </Controls:PanoramaItem>
                    </Controls:Panorama>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Grid>

这个设计器的类文件是这样的

  public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();
        PanoramaItem panItem = new PanoramaItem();
        List<ImageList> imgList = new List<ImageList>();

        imgList.Add(new ImageList() { ImageName = ImagePath.Image4 });
        lbImages.ItemsSource = imgList;
    }
    public class ImageList
    {
        public string ImageName { get; set; }
    }
}

这实际上工作顺利,看起来也不错…要达到你想要达到的目标,几乎没有别的方法了。请让我知道这是否有效。如果这对你不起作用,我会建议其他人!