Tell me how to make the file sharing service open at the touch of a button and suggest choosing a file, and then it would be displayed in a ListView.
1 answer
Opening a dialog with FileOpenPicker
. Description link: FileOpenPicker Class
Image display using BitmapImage
link: BitmapImage class . Useful link: Image.Source Property
The links have a detailed description and examples.
Create an Image object in XAML, with no source and any other property values. And the C # code will look something like this:
FileOpenPicker open = new FileOpenPicker(); StorageFile file = await open.PickSingleFileAsync(); if (file != null) { using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.DecodePixelWidth = 600; await bitmapImage.SetSourceAsync(fileStream); Scenario2Image.Source = bitmapImage; } }
Use the SetSourceAsync method if you use image sources that are available for specifying Image objects only at run time, such as image files that a user can select by opening FileOpenPicker in the user interface.
- And can I, as a beginner, add some comments after the condition?) - Denisok
- @Denisok, open here this article Image.Source - here is described in some detail, I think you will understand. - Denis Bubnov
- And you can still ask a question, how to save the downloaded images, as an object, or is the path simple? (for example, if I save every link from the Internet to Iist and build a GridView on it) - Denisok
|
файлообменник
? - sp7