-
August 5th, 2013, 05:47 AM
#1
[RESOLVED] [2012] Windows Store Application: Image Source
OK, this really sucks!
I just want to display a picture from a dynamically created path.
This is my code :
Code:
Private arrFolderNames() As String
Private arrSubFolderNames() As String
Private arrFileNames() As String
Private Async Sub btSelect_Click(sender As Object, e As RoutedEventArgs) Handles btSelect.Click
Dim RootFolder As StorageFolder = KnownFolders.PicturesLibrary
Dim FolderList As IReadOnlyList(Of IStorageItem) = Await RootFolder.GetItemsAsync
Dim Counter As Integer
For Each folder In FolderList
If TypeOf folder Is StorageFolder Then
lstFolders.Items.Add(folder.Name)
ReDim Preserve arrFolderNames(Counter)
arrFolderNames(Counter) = folder.Path
Counter += 1
End If
Next
End Sub
Private Async Sub lstFolders_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles lstFolders.SelectionChanged
Dim SubFolder As StorageFolder = Await StorageFolder.GetFolderFromPathAsync(arrFolderNames(lstFolders.SelectedIndex))
Dim SubFolderList As IReadOnlyList(Of IStorageItem) = Await SubFolder.GetItemsAsync
Dim Counter As Integer
For Each Folder In SubFolderList
If TypeOf Folder Is StorageFolder Then
lstSubFolders.Items.Add(Folder.Name)
ReDim Preserve arrSubFolderNames(Counter)
arrSubFolderNames(Counter) = Folder.Path
Counter += 1
End If
Next
End Sub
Private Async Sub lstSubFolders_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles lstSubFolders.SelectionChanged
Dim SubFolder As StorageFolder = Await StorageFolder.GetFolderFromPathAsync(arrSubFolderNames(lstSubFolders.SelectedIndex))
Dim SubFolderList As IReadOnlyList(Of IStorageItem) = Await SubFolder.GetItemsAsync
Dim Counter As String
For Each File In SubFolderList
If TypeOf File Is StorageFile Then
lstFiles.Items.Add(File.Name)
ReDim Preserve arrFileNames(Counter)
arrFileNames(Counter) = File.Path
Counter += 1
End If
Next
End Sub
Private Sub lstFiles_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles lstFiles.SelectionChanged
Dim TempImage As New BitmapImage()
Dim strPicLoc As String = arrFileNames(lstFiles.SelectedIndex)
TempImage.UriSource = New Uri(strPicLoc, UriKind.Absolute)
imgWall.Stretch = Stretch.Fill
imgWall.Source = TempImage
End Sub
As you can probably see, I continously build a file path. First, I store the main folder path, then the selected subfolder path, and finally the file name inside a particular sub folder.
Now, I want to display the picture ( which is the selected file ) inside an Image control.
I have set breakpoints and my URI is correct and by all sense it should show the picture - which it doesn't
I searched everywhere and MSDN's help is so useless, I have literally tried each and every example on there to no avail!
Is there some magic trick I should know?
Hannes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|