Show.XAML
<Viewbox x:Name="viewBoxBig" HorizontalAlignment="Left" Width="1366" Margin="0,0,0,-52" SizeChanged="viewBox_SizeChanged" Grid.RowSpan="2">
<FlipView x:Name="fvShow" BorderBrush="Black" BorderThickness="0" HorizontalAlignment="Left" Grid.Row="1" Width="1366" Margin="0,5,0,0" Height="708" >
<FlipView.ItemTemplate>
<DataTemplate>
<Grid>
<ScrollViewer x:Name="scrollViewer" BorderThickness="0" HorizontalAlignment="Center" ZoomMode="Enabled" MaxZoomFactor="20" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<StackPanel>
<Image x:Name="imgBig" Visibility="Collapsed" HorizontalAlignment="Left" Grid.Row="1" Source="{Binding ImageBig}" Stretch="UniformToFill"/>
</StackPanel>
</ScrollViewer>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
<FlipView Height="100" Width="100"/>
</FlipView>
</Viewbox>
Show.XAML.CS
async private void Open()
{
ObservableCollection<ImageItem> imageItemListBig = new ObservableCollection<ImageItem>();
ObservableCollection<ImageItem> imageItemListSmall = new ObservableCollection<ImageItem>();
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".gif");
openPicker.FileTypeFilter.Add(".png");
openPicker.FileTypeFilter.Add(".bmp");
var fileList = await openPicker.PickMultipleFilesAsync();
if (fileList.Count > 0)
{
foreach (var item in fileList)
{
//原图
IRandomAccessStream randomAccessStream = await item.OpenReadAsync();
ImageItem imageItemBig = new ImageItem();
imageItemBig.ImageBig.SetSource(randomAccessStream);
imageItemListBig.Add(imageItemBig);
}
}
fvShow.ItemsSource = imageItemListBig;
}
ImageIteam.cs
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
//原图
private BitmapImage _ImageBig = new BitmapImage();
public BitmapImage ImageBig
{
get
{
return _ImageBig;
}
set
{
if (_ImageBig != value)
{
_ImageBig = value; this.OnPropertyChanged("ImageBig");
}
}
}
//原图
public void SetImageBig(String path)
{
ImageBig = new BitmapImage(new Uri(path));
}
转载于:https://www.cnblogs.com/louyuhao/archive/2012/07/11/2586156.html