【问题标题】:showing Image swapping like picture gallery in Windows Phone C#在 Windows Phone C# 中显示像图片库一样的图像交换
【发布时间】:2013-04-27 06:20:55
【问题描述】:

我无法像 windows phone 中的图片库那样平滑切换。

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

我试图搜索但没有得到任何答案。我正在尝试以图库视图的方式显示图像列表。过去 3 天我一直在苦苦挣扎。如果您给我一些建议或链接,这将是一个帮助。

【问题讨论】:

  • 你的问题不是很清楚。当您说平滑时,您的意思是它没有动画还是动画以非常低的帧速率运行?
  • @dr.mo 让我澄清一下。我有一个图像列表,现在我想像在 Windows 手机中查看照片库图像视图一样查看它。我在这里没有做任何动画,我只是将图像从左向右移动,反之亦然以查看列表中的所有图像。我可以做到这一点,但是您在 windows phone 画廊中找到的动画来查看我无法做到的图像。它应该像画廊一样工作。请帮帮我...
  • @SanghatiMukherjee 您想在一个屏幕上查看一张接一张的图片还是查看图片列表?如果您让我知道您想要哪一个,我会想到可以工作的东西..我会尝试给您代码或告诉您如何完成..
  • @apoorva 我想要第一个选项,即从左到右依次查看一张图片……就像 Windows 手机中的画廊一样。如果您有一些建议或代码,这将是一个帮助..
  • 我有一个建议.. 采取全景控制并动态创建全景项目并将每张图片绑定到每个全景项目

标签: c# windows-phone-7 windows-phone-8 galleryview windowsphotogallery


【解决方案1】:

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

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

这实际上运行顺利,看起来也不错。. 实现您正在尝试的目标的方法很少。请让我知道这是否有效。如果这对你不起作用,我会建议其他人!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    相关资源
    最近更新 更多