ich versuche, alle Bilder von Standard-Bild-Bibliothek zu ListView in Windows-app zu zeigen, aber ich bin nur in der Lage, die Namen der Bilder nicht alle Bilder aus dem Ordner, hier ist mein Code.füllen Bilder von Bildbibliothek zu ListView in Windows 10 App
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Media.Imaging;
using Windows.Storage.Streams;
using Windows.Storage;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ListView
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
showall();
}
public async void showall()
{
IReadOnlyList<StorageFile> file = await KnownFolders.PicturesLibrary.GetFilesAsync();
foreach (StorageFile file1 in file)
{
list.Items.Add(file1.Name);
}
}
hier ist der XAML-Code ...
<Page
x:Class="ListView.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ListView"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<StackPanel HorizontalAlignment="Left" Width="350" Height="350">
<ListView Width="300" Height="300" Name="list" SelectionChanged="list_SelectionChanged">
<Image Width="200" Height="200" Name="img"></Image>
</ListView>
</StackPanel>
<StackPanel VerticalAlignment="Top">
<Image Width="300" Height="300" Name="img1" />
<TextBlock Width="300" Height="30" Name="txt1" />
</StackPanel>
</StackPanel>
</Grid>
Bildlink von Listview Entwurf wird: http://prntscr.com/djhu3f –
Also, was ist das prob lem? Wo ist dein XAML zum Binden das? – AVK
@AVKNaidu BEARBEITEN Überprüfen Sie oben –