想要用照片创建一个有趣的应用程序。这是场景:
这是我想解决的问题:
答案 0 :(得分:1)
a)简单的方法是简单地处理缩略图的ManipulationStarted方法并将该缩略图设置为当前缩略图。此外,处理较大的照片的ManipulationStarted方法并检查是否存在current thumbnail
。如果是这样,请将较大照片的图像源设置为缩略图流的图像源。
b)如果您需要透明度,则必须使用PNG。如果您不需要透明度,请使用JPG(以提高效率)。
c)将缩略图的图像源设置为null
以清除它。
编辑 - 这是做你想做的事的一种方式。当然,您可能希望使用UserControls而不是单个图像。
//class level variable that holds your current selected image
BitmapImage currentBitmap;
//Create an event handler to know when your page is loaded
public MyImagePage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MyImagePage_Loaded);
}
//Handle your Page Loaded event
void MyImagePage_Loaded(object sender, RoutedEventArgs e)
{
//Assign your thumbnail image control a picture
imgThumbnail.Source = new BitmapImage(new Uri("thumbnail.jpg", UriKind.Relative));
//Assign your large photo a default image (without an image, Manipulation methods won't be detected)
imgLarge.Source = new BitmapImage(new Uri("largeImage.jpg", UriKind.Relative));
//Make the current bitmap null
currentBitmap = null;
}
//Handle the ManipulationStarted event for your thumbnail image
private void imgThumbnail_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
//Set the currentImage to be that of the thumbnail
currentImage = (BitmapImage)imgThumbnail.Source;
}
//Handle the ManipulationStarted event for your large image
private void imgLarge_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
//check if the current image is null. If it's not, set the source for the large image
//to be that of the current image
if (currentImage != null)
imgLarge.Source = currentImage;
}
这是它背后的基础知识。您可以为具有指向较大版本图像的属性的缩略图创建类/ UserControl。然后,您可以将imgLarge
源设置为较大版本图像的源。
希望有所帮助。