C# 显示选定目录中的照片

C# 显示选定目录中的照片,c#,xaml,photo-gallery,C#,Xaml,Photo Gallery,我正在做一个图像库的小项目,学习如何编程,我现在要做的是选择一个目录,所有的图像都会显示出来。这就是我现在拥有的 .xaml <Grid x:Name="gridGallery" Height="610.667" Margin="205,70,0,0" Width="1058.338"> <ListBox x:Name="listBoxGallery">

我正在做一个图像库的小项目,学习如何编程,我现在要做的是选择一个目录,所有的图像都会显示出来。这就是我现在拥有的

.xaml

<Grid x:Name="gridGallery" Height="610.667" Margin="205,70,0,0" Width="1058.338">
     <ListBox x:Name="listBoxGallery">
          <ListBox.ItemTemplate>
               <DataTemplate>
                    <StackPanel Orientation="Vertical">
                         <Image Margin="5" Source="{Binding Path}" Height="150" Stretch="Uniform"/>
                         <TextBlock Margin="5" Text="{Binding Name}"/>
                    </StackPanel>
               </DataTemplate>
          </ListBox.ItemTemplate>
     </ListBox>
</Grid>

我不知道我是否做错了什么,也不知道在我选择目录后要添加什么,任何帮助都会很棒。

从您的代码中不清楚哪些没有发生,哪些应该发生。您到底在寻求什么指导?请查看此链接,它可能会有所帮助:
private void ButtonDirectory_Click(object sender, RoutedEventArgs e)
{
     var dialog = new CommonOpenFileDialog
     {
          DefaultDirectory = "Photos",
          IsFolderPicker = true
     };
     if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
     {
          //adds all photos in the selected folder to gallery
     }
}