2
在我的xaml文件中,我有一個名爲OutputImg的圖像。 我還有一個名爲OutputTB的文本塊,用於顯示圖像的名稱和一個按鈕,讓我從我的圖片文件夾中選擇圖像。背後在項目之外添加圖像C#Windows Store應用程序
代碼:
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = Picker.ViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.PicutresLiibrary;
openPicker.FileTypeFilter.Add(".png");
StorageFile.file = await openPicker.PickSingleFileAsync();
OutputTB.text = file.Name;
BitmapImage image = new BitmapImage(new Uri(file.path));
OutputImg.Source = image;
}
問題是,即使我沒有得到任何錯誤,我的圖片將不會顯示。它將圖片的名稱寫出到OutputTB.text,但圖像只保留爲空。如何使我的選定圖像顯示在OutputImg圖像框中。
據我瞭解,有可能是我在這裏失蹤一個很基本的事情,但它只是意味着是一個學習項目