在我的Metro应用中,我想上传一个image
。实际上button-click
,应该打开文件浏览器并提示输入图像。当用户选择任何图像时,我想view
使用image
标签显示它并将其保存在服务器端。我有以下图像和按钮代码:
<Border Margin="0,30,0,0" BorderThickness="2" BorderBrush="#FFAAA7A7" HorizontalAlignment="Center" Height="113">
<Image Height="101" Source="temp.png" Margin="0,-2,0,10"/>
</Border>
<AppBarButton HorizontalAlignment="Center" Label="Upload Image" VerticalAlignment="Center" Icon="Camera" Width="178" Margin="0,0,0,0" Click="AppBarButton_Click" />
您正在搜索“文件选择器”对话框。这是一篇很好的文章。以下代码可以:
此代码取自页面:
if (rootPage.EnsureUnsnapped())
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
//OutputTextBlock.Text = "Picked photo: " + file.Name;
}
else
{
//OutputTextBlock.Text = "Operation cancelled.";
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句